Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2026177
  • 博文数量: 413
  • 博客积分: 10926
  • 博客等级: 上将
  • 技术积分: 3862
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-09 18:14
文章分类

全部博文(413)

文章存档

2015年(5)

2014年(1)

2013年(5)

2012年(6)

2011年(138)

2010年(85)

2009年(42)

2008年(46)

2007年(26)

2006年(59)

分类: C/C++

2009-06-05 16:10:14

  1. NSObject
    NSObject is the root class of most Objective-C class hierarchies.
  2. NSNumber
  3. NSAutoReleasePool
  4. NSString,NSMutableString
    Contains unicode characters. i.e.: @"This is Objective-C string";

    Whereas C-style strings consist of  char characters, NSString objects consist of  unichar characters.A  unichar character is a multibyte character according to the Unicode standard.This enables you to work with character sets that can contain literally millions of characters.

    The  NSString class deals with immutable strings.

    The NSMutableString class can be used to create string objects whose characters can be
    changed.
  5. NSLog
  6. NSArray, NSMutableArray
    Its elements are offen of one type, but that is not required (can be of different types)
  7. NSDictionary/NSMutableDictionary
    Is a connection of key-value pairs
  8. NSSet/NSMutableSet
    Is a connection of unique object.
  9. NSData
    NSData class provides an easy way to set up a buffer, read the
    contents of the file into it, or write the contents of a buffer out to a file.
  10. File Operation
     I) NSFileManager
        Manage files and directories
     II) NSFileHandle
        Handle File I/O   
     III) Path utils
      a) The methods declared in NSPathUtilities.h. In fact, they are defined in NSString category, such as NSString:pathExtension:, NSString:pathComponents: etc.
      b)
        * NSFullUserName
        * NSHomeDirectory
        * NSHomeDirectoryForUser
        * NSOpenStepRootDirectory
        * NSSearchPathForDirectoriesInDomains
        * NSTemporaryDirectory
        * NSUserName
     IV) NSProcessInfo
        Get/Set Process information, such as arguments, environment, process name, host name, system name, memory etc.
  11. Memory Management: Autorelease Pool
     I) Create autorelease pool
        NSAutoReleasePool *pool = [[NSAutoReleasePool alloc] init];
     II) Destroy autorelease pool
        [pool drain]
     III) Add objects to autorelease pool
        Foundation automatically adds arrays, strings, dictionarys, and other objects to the autorelease pool. If you don't use foundation framework (such class doesn't inherit from class from foundation framework), you can call [YourObject autorelease] to add your object to autorelease pool.
     IV) Reference Counting
      [AClass alloc] reference count it set to 1,
      [AObject retain] increase reference count of AObject by 1. This method is offen called automatically when you call Foundation method, such as add objects to an array, but assign operator "=" will not affect reference count
      [AObject release] decrease reference count by 1. This method is offten called automatically also when you call Foundation method, such as remove objects from an array. If reference count is 0, the object is no longer used, autoreleas pool will free memory used by that object.
      [AObject retainCount] get current reference count;
     V) If your program generates a lot of temporary object (This easily happen when executing code inside a loop ), you can create multiple autorelease pool, i.e.:
      for( i = 0; i < XXX: i++)
      {
        NSAutoReleasePool *poolTmp = [[NSAutoReleasePool alloc] init];
        //Lots of work with temporary objects here.
       [poolTmp drain];
      }
     VI) Additional Notes
       a) If current autorelease pool is destroyed by calling [pool drain], and then create a new one, you must call [obj autorelease] to add object to new autorelease pool;
       b) Destroy autorelease pool by calling [pool drain] will not affect reference count of objects in the autorelease pool;
       c) Add objects to autorelease pool by calling [obj autorelease] will not affect its reference count.
       d) In addition to autorelease pool, Objective-C has garbage collection, like that for Java, but for some releases(please refer to the book), we'd better use autorelease pool,
  12. Garbage Collection
    As of Objective C 2.0, an alternate form of memory management, known as garbage
    collection, became available.With garbage collection, you don’t have to worry about retaining and releasing objects, autorelease pools, or retain counts.The system automatically keeps tracks of what objects own what other objects, automatically freeing up (or garbagecollecting) objects that are no longer referenced as space is needed during the program’s execution.

    When garbage collection is enabled, your program can still make its  retain ,
    autorelease , release , and  dealloc method calls. However, they’ll all be ignored.
  13. NSCopying, NSMutableCopying
    A protocol to copy objects
阅读(1864) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~