mardi 5 mai 2015

Watchkit -application: handleWatchKitExtensionRequest error

I'm getting the following error when requesting a dictionary of XML items via the above method:

> NSLocalizedDescription=The UIApplicationDelegate in the iPhone App never called reply() in -[UIApplicationDelegate application:handleWatchKitExtensionRequest:reply:]

I have no problem passing an NSDictionary consisting of an NSMutableArray of NSStrings.

From the interface controller:

- (void) requestFeedsFromPhone
{
    [WKInterfaceController openParentApplication:@{@"request":@"feeds"}
                                       reply:^(NSDictionary *replyInfo, NSError *error) {

                                           // the request was successful
                                           if(error == nil) {

                                               // get the array of items
                                               NSMutableDictionary *tempDictionary = replyInfo[@"feeds"];


                                               NSLog(@"tempDictionary: %@", tempDictionary[@"feedsArray"]);
                                               self.feeds = tempDictionary[@"feedsArray"];
                                               [self setupTable];
                                           }
                                           else{
                                               NSLog(@"ERROR: %@", error);
                                           }
                                       }];
}

In the app delegate:

- (void) application:(UIApplication *)application
handleWatchKitExtensionRequest:(NSDictionary *)userInfo
           reply:(void (^)(NSDictionary *))reply
{

    MasterViewController *mainController = (MasterViewController*)  self.window.rootViewController;

    //this is the troublesome line - calling this method results in the error
    NSDictionary *feedsDictionary = [mainController returnFeedsDictionary];

    reply(@{@"feeds": feedsDictionary});
}

In the MasterViewController:

-(NSDictionary *) returnFeedsDictionary
{

    NSURL *url = [NSURL URLWithString:@"http://ift.tt/1PmtTl3"];
    SeparateParser *separateParser = [[SeparateParser alloc] initWithURL:url];
    [separateParser parse];
    NSArray *tempArray = [separateParser returnFeeds];
    return @{@"feedsArray": tempArray};

}

The returnFeeds method returns an NSMutableArray of NSMutableDictionarys filled with NSMutableStrings (title, link, imageURL, etc).

I'm assuming my problem is that some of my data isn't property list compliant but I thought arrays, strings, and dictionaries were acceptable.

Aucun commentaire:

Enregistrer un commentaire