GPGKeyedModel Class Reference

GPGKeyedModel Class Reference

Overview

Deprecated.

Use the data loading methods in the class representing a specific Play Games feature instead. For example, to load Achievement metadata, you can implement the following code:

[GPGAchievementMetadata metadataForAchievementId:achievementId
    completionHandler:(GPGAchievementMetadata *metadata, NSError *error) {
 }];

A generic model for accessing data through keys.

This model object abstracts the general process of loading data and checking its current state. This class is designed to be subclassed and not instantiated directly. A practical implementation of this model is found in GPGApplicationModel, which contains all of the sub-models for the current application.

There are two ways to interact with data: blocks and notifications.

Loading Data With Blocks

When you want to load any model data it is recommended that you use the GPGApplicationModel::loadDataForKey:completionHandler: method. The completion handler will be called once the data is available.

Example:

[[GPGManager sharedInstance].applicationModel loadDataForKey:GPGModelAllAchievementMetadataKey
                                           completionHandler:
 ^(NSError *error) {
   if (nil == error) {
   }
 }];

Using Notifications to Listen for Data Changes

If you need to listen for changes to the model data then you should register for a model change notification.

Example:

NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];

[nc addObserver:self selector:@selector(leaderboardMetadataDidChange:)
                         name:GPGModelAllLeaderboardMetadataKey
                       object:[GPGManager sharedInstance].applicationModel];
Inheritance diagram for GPGKeyedModel:
GPGApplicationModel

Public Member Functions

Querying Data
(void) - loadDataForKey:
 Deprecated.
(void) - loadDataForKey:completionHandler:
 Deprecated.
(void) - reloadDataForKey:
 Deprecated.
(void) - reloadDataForKey:completionHandler:
 Deprecated.
(BOOL) - isLoadingDataForKey:
 Deprecated.
(BOOL) - isDataLoadedForKey:
 Deprecated.
(NSError *) - errorFromLoadingDataForKey:
 Deprecated.

Properties

NSMutableDictionary * keyToCompletionHandlers
 Loading state.

Member Function Documentation

- (void) loadDataForKey: (NSString *)  key

Deprecated.

Initiates a request to load the given key's data if it has not already been loaded.

If the data is already loading then this method does nothing.

Threadsafe.

- (void) loadDataForKey: (NSString *)  key
completionHandler: (GPGModelDidLoadBlock)  completionHandler 

Deprecated.

Initiates a request to load the given key's data if it has not already been loaded. Calls the completion handler once the data is loaded.

If the data is already loaded then the completion handler will be called immediately.

Threadsafe.

Parameters:
completionHandler(optional) A block of the form: ^(NSError *error). Executes the completion handler immediately if the data is already loaded.
- (void) reloadDataForKey: (NSString *)  key

Deprecated.

Initiates a load request for the given key's data even if the data has already been loaded.

If the data is already loading then this method does nothing.

Threadsafe.

- (void) reloadDataForKey: (NSString *)  key
completionHandler: (GPGModelDidLoadBlock)  completionHandler 

Deprecated.

Initiates a load request for the given key's data even if the data has already been loaded. Calls the completion handler once the data is loaded.

If the data is already loading then this method does nothing. If the data is already loaded the completion handler will NOT be called immediately.

Threadsafe.

Parameters:
completionHandler(optional) A block of the form: ^(NSError *error).
- (BOOL) isLoadingDataForKey: (NSString *)  key

Deprecated.

Checks the current loading state of data for the given key.

Returns:
YES if the data for the given key is currently being loaded, NO otherwise.
- (BOOL) isDataLoadedForKey: (NSString *)  key

Deprecated.

Returns YES if the data for the given key successfully loaded, otherwise returns NO if an error occurred or the data has not been loaded yet.

This can be YES if the data is currently loading and the data has already been loaded once before. When this is the case the data is refreshing and you should represent the user interface state accordingly.

- (NSError *) errorFromLoadingDataForKey: (NSString *)  key

Deprecated.

Returns the error for the given key if the data failed to load, otherwise returns nil.


Property Documentation

- (NSMutableDictionary*) keyToCompletionHandlers [read, copy]

Loading state.

Оставить отзыв о...

Текущей странице
Play Games Services for iOS
Play Games Services for iOS