FoundationExtension
FoundationExtension is common Foundation/UIKit/Cocoa shortcuts and snippets collection.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
NSArray(Creations) Category Reference

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...
 

Detailed Description

NSArray creation methods extension with NSData or NSFastEnumeration

Data must be property list.

Method Documentation

+ (instancetype) arrayWithData: (NSData *)  data

Creates and returns an array containing the contents of data. Data must be property list.

See also
initWithData:
+ (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.

See also
initWithData:format:error:
+ (instancetype) arrayWithEnumerator: (id< NSFastEnumeration >)  enumerator

Creates and returns an array containing the objects enumerated in a given enumerator.

See also
initWithEnumerator:
- (instancetype) initWithData: (NSData *)  data

Initializes a newly allocated array with the contents of data. Data must be property list.

Parameters
dataAn NSData object containing bytes of plist file representation.
Returns
An array initialized to contain the contents in data. Returns nil if the contents of the request can’t be parsed into an array. The returned object might be different than the original receiver.
See also
initWithData:format:error:
arrayWithData:format:error:
- (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.

Parameters
dataAn NSData object containing bytes of plist file representation.
formatA property list format. Possible values for format are described in NSPropertyListFormat.
errorIf the method does not complete successfully, upon return contains an NSError object that describes the problem.
Returns
An array initialized to contain the contents in data. Returns nil if the contents of the request can’t be parsed into an array. The returned object might be different than the original receiver.
See also
initWithData:
arrayWithData:
- (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.

Parameters
enumeratorAn object with NSFastEnumeration implementation
Returns
An array initialized to contain the objects — or if flag is YES, copies of the objects - enumerated in a given enumerator.
See also
initWithEnumerator:copyItems:
- (instancetype) initWithEnumerator: (id< NSFastEnumeration >)  enumerator
copyItems: (BOOL)  flag 

Initializes a newly allocated array by placing in it the objects enumerated in a given enumerator.

Warning
This initilizer is not optimized.
Parameters
enumeratorAn object with NSFastEnumeration implementation
flagIf 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.
Returns
An array initialized to contain the objects — or if flag is YES, copies of the objects - enumerated in a given enumerator.
See also
initWithEnumerator:
arrayWithEnumerator:
- (NSArray *) subarrayFromIndex: (NSUInteger)  index

Returns a new array containing the receiving array’s elements from the one at a given index to the end.

Parameters
indexAn index. The value must lie within the bounds of the receiver, or be equal to the length of the receiver.
Returns
A new array containing the elements of the receiver from the one at index to the end. If index is equal to the length of the array, returns an empty array.

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.

Parameters
fromIndexAn index. The value must lie within the bounds of the receiver, or be equal to the length of the receiver.
lengthA 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.
Returns
A new array containing the receiving array’s elements that fall within the limits specified by range made by fromIndex and length.
- (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.

Parameters
fromIndexAn index. The value must lie within the bounds of the receiver, or be equal to the length of the receiver.
toIndexAn index. The value must lie within the bounds of the receiver, or be equal to the length of the receiver.
Returns
A new array containing the receiving array’s elements of the receiver from the one at fromIndex to up to, but not including, the one at toIndex.

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.

Parameters
indexAn index. The value must lie within the bounds of the receiver, or be equal to the length of the receiver.
Returns
A new array containing the receiving array’s elements of the receiver up to, but not including, the one at anIndex. If anIndex is equal to the length of the array, returns a copy of the receiver.

Raises an NSRangeException if (anIndex - 1) lies beyond the end of the receiver.


The documentation for this category was generated from the following file: