Note that there are some explanatory texts on larger screens.

plurals
  1. POI can't perform a selector from another file in iOS
    primarykey
    data
    text
    <p>I'm trying to implement my own Api in iOS but I have one problem with callbacks.</p> <p>I have implemented my callbacks with selectors but, when the function given is in another file/class, the app crashes.</p> <p>This is the error:</p> <pre><code>2013-09-18 21:32:16.278 Vuqio[6498:19703] -[VuqioApi postCurrenProgramRequestDidEnd]: unrecognized selector sent to instance 0xa5a2150 2013-09-18 21:32:16.278 Vuqio[6498:19703] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[VuqioApi postCurrenProgramRequestDidEnd]: unrecognized selector sent to instance 0xa5a2150' </code></pre> <p>An this my code:</p> <p>Call: (File Controller.m)</p> <pre><code>... [self softCheckIn:@"922337065874264868506e30fda-1c2a-40a5-944e-1a2a13e95e95" inProgram:p.idProgram callback:@selector(postCurrenProgramRequestDidEnd)]; ... -(void)postCurrenProgramRequestDidEnd { NSLog(@"Soft check-in"); } - (void)softCheckIn:(NSString *)userId inProgram:(NSString *)program callback:(SEL)callback { // Hacemos un soft checkin VuqioApi *api = [[VuqioApi alloc] init]; NSMutableDictionary *data = [[NSMutableDictionary alloc] initWithObjectsAndKeys: userId, @"userId", program, @"programId", nil]; [api postCurrentProgram:data withSuccess:callback andFailure:@selector(aaa)]; } </code></pre> <p>Methods: (File Api.m)</p> <pre><code>- (void)postCurrentProgram:(NSDictionary *)data withSuccess:(SEL)successCallback { NSLog(@"Performing selector: %@", NSStringFromSelector(successCallback)); [self postCurrentProgram:data withSuccess:successCallback andFailure:@selector(defaultFailureCallback)]; } - (void) postCurrentProgram:(NSDictionary *)data withSuccess:(SEL)successCallback andFailure:(SEL)failureCallback { [self placePostRequest:@"api/programcurrent" withData:data withHandler:^(NSURLResponse *urlResponse, NSData *rawData, NSError *error) { NSLog(@"Performing selector: %@", NSStringFromSelector(successCallback)); NSLog(@"Performing selector: %@", NSStringFromSelector(failureCallback)); NSString *string = [[NSString alloc] initWithData:rawData encoding:NSUTF8StringEncoding]; //NSDictionary *json = [NSJSONSerialization JSONObjectWithData:rawData options:0 error:nil]; if ( ![string isEqual: @"ok"]) { [self performSelector:failureCallback withObject:self]; } else { NSLog(@"OK"); [self performSelector:successCallback]; } }]; } - (void) defaultFailureCallback { NSLog(@"Failure"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload