Nsset application developed for iOS

Source: Internet
Author: User

NSSet, NSMutableSet, and NSCountedSet classes declare an unordered set of programming interface objects (hashed storage: The storage location in the memory is not continuous ).

The NSArray and NSDictionary classes declare an ordered set of programming interface objects (ordered storage: sequential storage in memory ).

NSSet and NSMutableSet are the same as NSArray and NSMutableArray. NSSet declares static objects. When an NSSet object is created, the subsequent climate entries cannot be modified. The NSMutableSet object can be dynamically added or deleted, and the memory is automatically allocated according to the object length.

Note that only cocoa objects can be added to NSSet and NSArray. To add basic data types (int, float, BOOL, double, etc.), encapsulate the data into NSNumber.

NSSet is not much different from NSArray in actual application, but if you want to find an element in NSArray, You need to traverse the entire array, which is inefficient. NSSet directly finds the position of a specific element based on the hash algorithm, which is highly efficient.

NSSet

-(NSArray *) allObjects;

-(Id) anyObject;

-(BOOL) containsObject :( id) anObject;

-(NSString *) description;

-(NSString *) descriptionWithLocale :( id) locale;

-(BOOL) intersectsSet :( NSSet *) otherSet;

-(BOOL) isEqualToSet :( NSSet *) otherSet;

-(BOOL) isSubsetOfSet :( NSSet *) otherSet;

+ (Id) set;

+ (Id) setWithObject :( id) object;

+ (Id) setWithObjects :( const
Id *) objects count :( NSUInteger) cnt;

+ (Id) setWithObjects :( id) firstObj ,...
NS_REQUIRES_NIL_TERMINATION;

+ (Id) setWithSet :( NSSet *) set;

+ (Id) setWithArray :( NSArray *) array;

-(Id) initWithObjects :( const
Id *) objects count :( NSUInteger) cnt;

-(Id) initWithObjects :( id) firstObj ,...
NS_REQUIRES_NIL_TERMINATION;

-(Id) initWithSet :( NSSet *) set;

-(Id) initWithSet :( NSSet *) set copyItems :( BOOL) flag;

-(Id) initWithArray :( NSArray *) array;

NSMutableSet (NSExtendedMutableSet)

-(Void) addObjectsFromArray :( NSArray *) array;

-(Void) intersectSet :( NSSet *) otherSet;

-(Void) minusSet :( NSSet *) otherSet;

-(Void) removeAllObjects;

-(Void) unionset :( nsset *) otherset;

-(Void) setset :( nsset *) otherset;

+ (ID) setwithcapacity :( nsuinteger) numitems;

-(ID) initwithcapacity :( nsuinteger) numitems;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.