集合 - 1

Cocoa 中的集合有NSArray(NSMutableArray), NSSet (NSMutableSet, NSCountedSet), NSDictionary (NSMutableDictionary)

 

NSArray

-(unsigned) count

-(id) objectAtIndex:(unsigned) index

-(BOOL) containsObject:(id) anObject

 

NSMutableArray

-(void) addObject:(id) anObject

-(void) insertObject:(id) anObject atIndex:(unsigned) index

-(void) removeObjectAtIndex:(unsigned) index

-(void) removeObject:(id) object

 

NSDictionary

-(unsigned) count

-(id) objectForKey:(id) aKey

-(NSArray *) allKeys

 

NSMutableDictionary

-(void) setObject:(id) anObject forKey:(id) aKey

-(void) removeObjectForKey:(id) aKey

 

//操作plist

-(id) initWithContentsOfFile:(NSString *) aPath

-(BOOL) writeToFile:(NSString *) path atomically:(BOOL) flag

 

 獲取地址簿記錄 (加入AddressBook 框架)

#import <AddressBook/AddressBook.h>

 

ABAddressBook * book = [ABAddressBook sharedAddressBook];

NSArray *people = [book people];

NSString *firstName = [people valueForProperty:@"First"];

NSString *lastName = [people valueForProperty:@"Last"];

 

發佈了40 篇原創文章 · 獲贊 0 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章