FoundationExtension
FoundationExtension is common Foundation/UIKit/Cocoa shortcuts and snippets collection.
|
NSArray creation methods extension with NSData or NSFastEnumeration More...
#import <NSArray.h>
Instance Methods | |
Initializing an Array | |
(instancetype) | - initWithData: |
Initializes a newly allocated array with the contents of data. Data must be property list. More... | |
(instancetype) | - initWithData:format:error: |
Initializes a newly allocated array with the contents of data. Data must be property list. More... | |
(instancetype) | - initWithEnumerator: |
Initializes a newly allocated array by placing in it the objects enumerated in a given enumerator. More... | |
(instancetype) | - initWithEnumerator:copyItems: |
Initializes a newly allocated array by placing in it the objects enumerated in a given enumerator. More... | |
Creating an Array | |
(NSArray *) | - subarrayFromIndex: |
Returns a new array containing the receiving array’s elements from the one at a given index to the end. More... | |
(NSArray *) | - subarrayToIndex: |
Returns a new array containing the receiving array’s elements of the receiver up to, but not including, the one at a given index. More... | |
(NSArray *) | - subarrayFromIndex:toIndex: |
Returns a new array containing the receiving array’s elements of the receiver from the one at a given index to up to, but not including, the one at a given index. More... | |
(NSArray *) | - subarrayFromIndex:length: |
Returns a new array containing the receiving array’s elements that fall within the limits specified by a given range made by fromIndex and length. More... | |
(instancetype) | + arrayWithData: |
Creates and returns an array containing the contents of data. Data must be property list. More... | |
(instancetype) | + arrayWithData:format:error: |
Creates and returns an array containing the contents of data. Data must be property list. More... | |
(instancetype) | + arrayWithEnumerator: |
Creates and returns an array containing the objects enumerated in a given enumerator. More... | |
NSArray creation methods extension with NSData or NSFastEnumeration
Data must be property list.
+ (instancetype) arrayWithData: | (NSData *) | data |
Creates and returns an array containing the contents of data. Data must be property list.
+ (instancetype) arrayWithData: | (NSData *) | data | |
format: | (NSPropertyListFormat *) | format | |
error: | (NSError **) | error | |
Creates and returns an array containing the contents of data. Data must be property list.
+ (instancetype) arrayWithEnumerator: | (id< NSFastEnumeration >) | enumerator |
Creates and returns an array containing the objects enumerated in a given enumerator.
- (instancetype) initWithData: | (NSData *) | data |
Initializes a newly allocated array with the contents of data. Data must be property list.
data | An NSData object containing bytes of plist file representation. |
- (instancetype) initWithData: | (NSData *) | data | |
format: | (NSPropertyListFormat *) | format | |
error: | (NSError **) | error | |
Initializes a newly allocated array with the contents of data. Data must be property list.
data | An NSData object containing bytes of plist file representation. |
format | A property list format. Possible values for format are described in NSPropertyListFormat. |
error | If the method does not complete successfully, upon return contains an NSError object that describes the problem. |
- (instancetype) initWithEnumerator: | (id< NSFastEnumeration >) | enumerator |
Initializes a newly allocated array by placing in it the objects enumerated in a given enumerator.
This initilizer is not optimized.
enumerator | An object with NSFastEnumeration implementation |
- (instancetype) initWithEnumerator: | (id< NSFastEnumeration >) | enumerator | |
copyItems: | (BOOL) | flag | |
Initializes a newly allocated array by placing in it the objects enumerated in a given enumerator.
enumerator | An object with NSFastEnumeration implementation |
flag | If YES, each object in array receives a copyWithZone: message to create a copy of the object—objects must conform to the NSCopying protocol. In a managed memory environment, this is instead of the retain message the object would otherwise receive. The object copy is then added to the returned array. If NO, then in a managed memory environment each object in array simply receives a retain message when it is added to the returned array. |
- (NSArray *) subarrayFromIndex: | (NSUInteger) | index |
Returns a new array containing the receiving array’s elements from the one at a given index to the end.
index | An index. The value must lie within the bounds of the receiver, or be equal to the length of the receiver. |
Raises an NSRangeException if (index - 1) lies beyond the end of the receiver.
- (NSArray *) subarrayFromIndex: | (NSUInteger) | fromIndex | |
length: | (NSUInteger) | length | |
Returns a new array containing the receiving array’s elements that fall within the limits specified by a given range made by fromIndex and length.
fromIndex | An index. The value must lie within the bounds of the receiver, or be equal to the length of the receiver. |
length | A length. The summation of the value and fromIndex must lie within the bounds of the receiver, or be equal to the length of the receiver. |
- (NSArray *) subarrayFromIndex: | (NSUInteger) | fromIndex | |
toIndex: | (NSUInteger) | toIndex | |
Returns a new array containing the receiving array’s elements of the receiver from the one at a given index to up to, but not including, the one at a given index.
fromIndex | An index. The value must lie within the bounds of the receiver, or be equal to the length of the receiver. |
toIndex | An index. The value must lie within the bounds of the receiver, or be equal to the length of the receiver. |
Raises an NSRangeException if (toIndex - 1) lies beyond the end of the receiver.
- (NSArray *) subarrayToIndex: | (NSUInteger) | index |
Returns a new array containing the receiving array’s elements of the receiver up to, but not including, the one at a given index.
index | An index. The value must lie within the bounds of the receiver, or be equal to the length of the receiver. |
Raises an NSRangeException if (anIndex - 1) lies beyond the end of the receiver.