HurkNburkS
HurkNburkS

Reputation: 5510

iOS Cloudsight error response crashing app

I am executing this code here

self.cloudSightQuery = [[CloudSightQuery alloc] initWithImage:imageData
                                              atLocation:CGPointZero
                                            withDelegate:self
                                             atPlacemark:nil
                                            withDeviceId:@""];
self.cloudSightQuery.queryDelegate = self;
[self.cloudSightQuery start];

However some times it crashes with the following reason

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ImageViewController cloudSightQueryDidFail:withError:]: unrecognized selector sent to instance 0x100514c40'

First throw call stack:

How am I able to capture this error and show the user a response as opposed to the app crashing?

Upvotes: 0

Views: 34

Answers (1)

Brad Folkens
Brad Folkens

Reputation: 986

Have you looked at the backtrace? You can use the debugger (in XCode) to show a backtrace.

The error itself indicates that there's an invalid method call [ImageViewController cloudSightQueryDidFail:withError:] sent to that instance (0x100514c40). Considering we're dealing with a delegate pattern, it seems likely that method was just never defined in your parent class and it's required by the protocol. You'll want to make sure to define that method first and then it should work.

TL;DR - You'll want to add this method to your delegate (self):

- (void)cloudSightQueryDidFail:(CloudSightQuery *)query withError:(NSError *)error
{
    // TODO: Fill in your logic here
    NSLog(@"query: %@, experienced an error: %@", query, error);
}

You can see an example of this at: https://github.com/cloudsight/cloudsight-objc/tree/master/Example-objc

Upvotes: 2

Related Questions