home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / OpenStepConversion / ConversionScripts / DefaultsConversion.tops < prev    next >
Encoding:
Text File  |  1996-08-30  |  5.7 KB  |  77 lines

  1.  
  2. /*********** DefaultsConversion: headers *************/
  3.  
  4. replace "#import <defaults/defaults.h>" with "#import <Foundation/NSUserDefaults.h>"
  5. replace "#include <defaults/defaults.h>" with "#include <Foundation/NSUserDefaults.h>"
  6.  
  7. /*********** DefaultsConversion: getting and setting *************/
  8.  
  9. replace "NXGetDefaultValue([[NSProcessInfo processInfo] processName], <default>)"
  10. with "[[[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithCString:<default>]] cString]"
  11.  
  12. replace "NXGetDefaultValue(<owner>, <default>)"
  13. with "[[[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithCString:<default>]] cString]"
  14.     warning "DefaultsConversion: This used to be a call to NXGetDefaultValue with the owner <owner>.  If the owner was different from your applications name, you may need to modify this code."
  15.  
  16. replace "NXSetDefault([[NSProcessInfo processInfo] processName], <default>, <value>)"
  17. with "[[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithCString:<value>] forKey:[NSString stringWithCString:<default>]]"
  18.  
  19. replace "NXSetDefault(<owner>, <default>, <value>)"
  20. with "[[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithCString:<value>] forKey:[NSString stringWithCString:<default>]]"
  21.     warning "DefaultsConversion: This used to be a call to NXSetDefault with the owner <owner>.  If the owner was different from your applications name, you may need to modify this code."
  22.  
  23. replace "NXReadDefault(<owner>, <default>)" with "([[NSUserDefaults standardUserDefaults] synchronize], [[[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithCString:<default>]] cString])"
  24.     warning "DefaultsConversion: If you were using NXReadDefault() to avoid searching the GLOBAL domain or to search a different domain than your app domain, you must set the NSUserDefault searchlist to the appropriate domains and use NSUserDefaults 'objectForKey:'"
  25.  
  26. /*********** DefaultsConversion: writing and removing (persistent) *************/
  27.  
  28. replace "NXRemoveDefault(<owner>, <default>)" with "[[NSUserDefaults standardUserDefaults] removeObjectForKey:[NSString stringWithCString:<default>]]"
  29.     warning "DefaultsConversion: [<NSUserDefaults> removeObjectForKey:...] used to be NXRemoveDefault(<owner>, <default>). Defaults will be synchronized within 30 seconds after this change.  For immediate synchronization, call '-synchronize'. Also note that the first argument of NXRemoveDefault is now ignored; to write into a domain other than the apps default, see the NSUserDefaults API."
  30.  
  31. replace "NXWriteDefault(<owner>, <default>, <value>)" with "[[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithCString:<value>] forKey:[NSString stringWithCString:<default>]]"
  32.     warning "DefaultsConversion: [<NSUserDefaults> setObject:...forKey:...] used to be NXWriteDefault(<owner>, <default>, <value>). Defaults will be synchronized within 30 seconds after this change.  For immediate synchronization, call '-synchronize'. Also note that the first argument of NXWriteDefault is now ignored; to write into a domain other than the apps default, see the NSUserDefaults API."
  33.  
  34. replace "NXWriteDefaults(<b args>)" with same
  35.     error "DefaultsConversion: NXWriteDefaults() is obsolete; use 'setObject:forKey:' instead"
  36.  
  37. /*********** DefaultsConversion: updating *************/
  38.  
  39. replace "<t tok> = NXUpdateDefault(<owner>, <default>)" with "[[NSUserDefaults standardUserDefaults] synchronize], <t tok> = [[[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithCString:<default>]] cString]"
  40.  
  41. replace "<t tok> = (char *)NXUpdateDefault(<owner>, <default>)" with "[[NSUserDefaults standardUserDefaults] synchronize], <t tok> = [[[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithCString:<default>]] cString]"
  42.     warning "DefaultsConversion: A call NXUpdateUserDefault() was converted here.  However you seemed to be casting the old return value of NXUpdateDefault to a (char *), stripping the constness.  The cast has been left out of the converted code.  If you are really modifying the return value through this casted pointer, you must modify the code to make a copy of the character buffer."
  43.  
  44. replace "NXUpdateDefault(<owner>, <default>)" with "[[NSUserDefaults standardUserDefaults] synchronize];"
  45.  
  46. replace "NXUpdateDefaults()" with "[[NSUserDefaults standardUserDefaults] synchronize]"
  47.  
  48. /*********** DefaultsConversion: registering defaults *************/
  49.  
  50. replace "NXDefaultsVector <b defaults>;" with same
  51.     error "DefaultsConversion: the NXDefaultsVector type is obsolete. Construct a dictionary of default registrations and use the NSUserDefaults 'registerDefaults:' method"
  52.  
  53. replace "NXRegisterDefaults(<b args>)" with same
  54.     error "DefaultsConversion: NXRegisterDefaults() is obsolete. Construct a dictionary of default registrations and use the NSUserDefaults 'registerDefaults:' method"
  55.  
  56. /*********** DefaultsConversion: setting the user *************/
  57.  
  58. replace "NXSetDefaultsUser(<b args>)" with same
  59.     error "DefaultsConversion: NXSetDefaultsUser() is obsolete; use [[NSUserDefaults alloc] initWithUser:<user>] to read another users defaults"
  60.  
  61. /*********** DefaultsConversion: string conversion cleanup *************/
  62.  
  63. replace "[NSString stringWithCString:[NSString stringWithCString:<aString>]]" with "[NSString stringWithCString:<aString>]"
  64.  
  65. replace "[[NSString stringWithCString:<aString>] cString]" with "<aString>"
  66.  
  67. replace "[[<aString> cString] cString]" with "[<aString> cString]"
  68.  
  69. replace "[NSString stringWithCString:[<aString> cString]]" with "<aString>"
  70.  
  71. replace "[NSString stringWithCString:@<string stringconst>]" with "@<string stringconst>"
  72.  
  73. replace "[NSString stringWithCString:<string stringconst>]" with "@<string stringconst>"
  74.  
  75. replace "[@<string stringconst> cString]" with "<string stringconst>"
  76.  
  77.