Declared in NSMutableArray+NSRails.h

Overview

This category on NSMutableArray allows mutable arrays to “fetch into themselves”.

The translateRemoteDictionariesIntoInstancesOfClass: method can also be useful if converting a manually-received array of JSON dictionaries and should be instances of a class.

Tasks

Instance Methods

remoteFetchAll:async:

Updates elements in this array.

- (void)remoteFetchAll:(Class)class async:(NSRBasicCompletionBlock)completionBlock

Parameters

class

Class with which to build instances to insert into this array. Raises an exception if this class does not subclass NSRRemoteObject.

completionBlock

Block to be executed on completion..

Discussion

Makes a GET request to /objects (where objects is the pluralization of class’s model name.)

Declared In

NSMutableArray+NSRails.h

remoteFetchAll:error:

Updates elements in this array.

- (BOOL)remoteFetchAll:(Class)class error:(NSError **)errorPtr

Parameters

class

Class with which to build instances to insert into this array. Raises an exception if this class does not subclass NSRRemoteObject.

errorPtr

Out parameter used if an error occurs while processing the request. May be NULL.

Return Value

YES if fetch was successful. Returns NO if an error occurred.

Discussion

Makes a GET request to /objects (where objects is the pluralization of class’s model name.)

Request made synchronously. See remoteFetchAll:async: for asynchronous operation.

Declared In

NSMutableArray+NSRails.h

remoteFetchAll:viaObject:async:

Updates elements in this array.

- (void)remoteFetchAll:(Class)class viaObject:(NSRRemoteObject *)parentObject async:(NSRBasicCompletionBlock)completionBlock

Parameters

class

Class with which to build instances to insert into this array. Raises an exception if this class does not subclass NSRRemoteObject.

parentObject

Remote object by which to request the collection from – establishes pattern for resources depending on nesting. Raises an exception if this object’s remoteID is nil, as it is used to construct the route.

completionBlock

Block to be executed on completion..

Discussion

Makes a GET request to /parents/3/objects (where parents/3 is the path for the parentObject, and objects is the pluralization of class’s model name.)

If viaObject is specified, will nest resource request (ex. GET to /parents/3/objects.)

Declared In

NSMutableArray+NSRails.h

remoteFetchAll:viaObject:error:

Updates elements in this array.

- (BOOL)remoteFetchAll:(Class)class viaObject:(NSRRemoteObject *)parentObject error:(NSError **)errorPtr

Parameters

class

Class with which to build instances to insert into this array. Raises an exception if this class does not subclass NSRRemoteObject.

parentObject

Remote object by which to request the collection from – establishes pattern for resources depending on nesting. Raises an exception if this object’s remoteID is nil, as it is used to construct the route.

errorPtr

Out parameter used if an error occurs while processing the request. May be NULL.

Return Value

YES if fetch was successful. Returns NO if an error occurred.

Discussion

Makes a GET request to /parents/3/objects (where parents/3 is the path for the parentObject, and objects is the pluralization of class’s model name.)

Request made synchronously. See remoteFetchAll:viaObject:async: for asynchronous operation.

Declared In

NSMutableArray+NSRails.h

translateRemoteDictionariesIntoInstancesOfClass:

Replaces each dictionary in this array with an instance of the given class, setting respective properties to those defined in that dictionary.

- (void)translateRemoteDictionariesIntoInstancesOfClass:(Class)class

Parameters

class

Class with which to build instances to replace this array’s dictionaries. Raises an exception if this class does not subclass NSRRemoteObject.

Discussion

This method can be useful when interpreting a retrieved array (representation of your server’s JSON out) from a remoteGET method or similar.

Declared In

NSMutableArray+NSRails.h