WhiteHouse / wh-app-ios

671 stars 260 forks source link

NINetworkRequestOperation not available in WHSearchController #3

Closed rainmaker2k closed 12 years ago

rainmaker2k commented 12 years ago

NINetworkRequestOperation doesn't seem to be available anymore in the nimbus library.

krishnenc commented 12 years ago

Its been deprecated in favour of AFNetworking it seems.

JeeLiu commented 12 years ago

NINetworkRequestOperation *op = [[NINetworkRequestOperation alloc] initWithURL:searchURL]; NINetworkRequestOperation doesn't find

marcobrambilla commented 12 years ago

Same issue here...

tonycelestino commented 12 years ago

Same issue and I was unable to find any information regarding this in their documentation.

krishnenc commented 12 years ago

You can migrate the functions that use NINetworkRequestOperation to use AFNetworking which is the default in Nimbus now:

ex:

    self.page = self.page + 1;
    NSString *formatString = AppConfig(@"SearchURLFormat");
    NSString *escaped = [[self class] escapeQueryParameter:query];
    NSURL *searchURL = [NSURL URLWithString:[NSString stringWithFormat:formatString, escaped, self.page]];
    DebugLog(@"Search URL = %@", searchURL);
    NSURLRequest *request = [NSURLRequest requestWithURL:searchURL];
    AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
        id results = [JSON objectForKey:@"results"];
        if (results && [results respondsToSelector:@selector(objectAtIndex:)]) {
            if (self.results) {
                self.results = [self.results arrayByAddingObjectsFromArray:results];
            } else {
                self.results = results;
            }
            [self.delegate searchControllerDidFindResults:self];
        }

    } failure:^(NSURLRequest *request, NSHTTPURLResponse *response,NSError *error,id JSON) {
        [self reportError:error];
    }];
    [operation start];
tonycelestino commented 12 years ago

Thanks @krishnenc , I'll try that later. Someone should send a Pull Request with these changes.

welschp commented 12 years ago

Thanks, all - this should be addressed. Closing this issue; if the problem continues please let us know