iOS Error - "unrecognized selector" - objective-c

Main.m
NSDictionary *additionalQueryParameters = [NSURL ab_parseURLQueryString:[url query]];
OAuth.h
#interface NSURL (OAuthAdditions)
+ (NSDictionary *)ab_parseURLQueryString:(NSString *)query;
#end
OAuth.m
#implementation NUSL (OAuthAdditions)
+ (NSDictionary *)ab_parseURLQueryString:(NSString *)query
{
does something..
}
When it runs that line, it throws this error...
2012-12-03 15:10:58.506[12500:1d403] +[NSURL ab_parseURLQueryString:]:
unrecognized selector sent to class 0xaece26c
2012-12-03 15:10:58.508[12500:1d403] * Terminating app due to
uncaught exception 'NSInvalidArgumentException', reason: '+[NSURL
ab_parseURLQueryString:]: unrecognized selector sent to class
0xaece26c'
* First throw call stack: (0xada8012 0xa3d6e7e 0xae332ad 0xad97bbc 0xad9794e 0x17b5ee8 0x17b5724 0x17b58d6 0xa84f53f 0xa861014 0xa8522e8
0xa851fcb 0x96097b24 0x960996fe) libc++abi.dylib: terminate called
throwing an exception
Any idea why it can't find it and how to fix it? Thanks.

Make sure OAuth.m is actually in the target and building in your project....

Your category implementation (OAuth.m) is named NUSL, not NSURL. The compiler is fine with the method since the category interface (header) is named correctly.

Related

Is there anyway to check if my app calls any method exclusive for iOS 8?

After testing my app in a iOS 7 device, I got a crash calling containsString from NSString, and then I realised that that methods has NS_AVAILABLE(10_10, 8_0);
Is there anyway to check automatically my program to see if there is any other method that is not available in iOS 7?
How is possible to compile and app with deployment target of 7.0 and not saying any warning or error in these cases?
-[__NSCFString containsString:]: unrecognized selector sent to instance 0x1702297c0
2015-10-23 12:03:37.655 WA[1434:60b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString containsString:]: unrecognized selector sent to instance 0x1702297c0'
* First throw call stack:
(0x183bd2f50 0x1900dc1fc 0x183bd7c04 0x183bd5930 0x183af55dc 0x1002a2c08 0x1000c71dc 0x1000caa88 0x1000c69bc 0x1000f3a4c 0x186c1055c 0x186c0ff08 0x186c099ec 0x186b9d8cc 0x186b9cad0 0x186c09044 0x1897bb504 0x1897bb030 0x183b92e90 0x183b92df0 0x183b91014 0x183ad1c20 0x186c081c8 0x186c02fdc 0x1000b6040 0x1906cfaa0)
libc++abi.dylib: terminating with uncaught exception of type NSException
You should use rangeOfString instead of containsString. Since rangeOfString available from iOS 2.0, you will not get crash on this.
Code snippets,
NSString *string = #"https://www.google.co.in/";
NSString *substring = #"http";
if ([oneContent rangeOfString:subString].location == NSNotFound) {
NSLog(#"string does not contain substring");
} else {
NSLog(#"string contains substring!");
}
Otherwise you can add category class for NSString and have a method like containsString: where you can implement the above code. It'll work dynamically.

KTPhotoBrowser push to KTTumbsViewController

I am trying to use KTPhotoBrowser to use its thumbnail view capabilities. I have some difficulties to push to the viewController that was derived from KTThumbsViewController. It seems the navigationController can only push to UIViewController:
- (void)showSDWebImageSample
{
KTThumbsViewController *newController = [[KTThumbsViewController alloc] init];
[self.navigationController pushViewController:newController animated:YES];
}
and the header file for KTThumbsViewController includes:
#interface KTThumbsViewController : UIViewController <KTThumbsViewDataSource>
I grabbed the code from the provided sample. But it gives me the following runtime error:
-[KTThumbsViewController copyWithZone:]: unrecognized selector sent to instance 0x8877130
2012-10-30 14:52:03.004 myCases_MD[36941:c07] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[KTThumbsViewController copyWithZone:]: unrecognized selector sent to instance 0x8877130'
Could anyone help me please?
Cheers,

how to solve run time error of [NSURL fileURLWithPath:error:]: unrecognized selector sent to class?

I am beginner in IPhone Developing. I want play sound. so, that's why I have apply this code
(void)viewDidLoad
{
NSError* err;
path=[[NSBundle mainBundle] pathForResource:#"Animalfile" ofType:#"plist"];
dict=[NSDictionary dictionaryWithContentsOfFile:path];
NSArray *animalaudio=[dict valueForKey:#"audio"];
NSString *audiolist=[animalaudio objectAtIndex:currentsound];
AVAudioPlayer *audio=[[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:audiolist error:&err]];
audio.delegate=self;
[audio play];
}
and I have got the run time error of
[NSURL fileURLWithPath:error:]: unrecognized selector sent to class 0x182121c
2012-07-14 14:51:21.711 plistdemo[1236:10703] *** Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: '+[NSURL fileURLWithPath:error:]:
unrecognized selector sent to class 0x182121c'
terminate called throwing an exceptionsharedlibrary apply-load-rules all
so, give any suggestion and source code which apply in my code
current documentation for NSURL doesn't list any such method like 'fileURLWithPath:error:'... seems like its either deprecated or incorrect.
instead try using something like:
[NSURL fileURLWithPath:audioList]
hope it helps...

program crashes when trying to present modal view controller

I want to load another xib, and use this simple code:
AddElementViewController *viewToLoad = [[AddElementViewController alloc] initWithNibName:#"AddElementViewController" bundle:nil];
viewToLoad.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:viewToLoad animated:YES];
for some reason it throws me out with this output:
2012-03-11 11:56:57.990 Weesh[14650:11603] -[MainViewController AddPressed:]: unrecognized selector sent to instance 0x7b55b40
2012-03-11 11:56:57.991 Weesh[14650:11603] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MainViewController AddPressed:]: unrecognized selector sent to instance 0x7b55b40'
*** First throw call stack:
(0x13da052 0x198ed0a 0x13dbced 0x1340f00 0x1340ce2 0x13dbec9 0x32a5c2 0x32a55a 0x3cfb76 0x3d003f 0x3cf2fe 0x34fa30 0x34fc56 0x336384 0x329aa9 0x22c7fa9 0x13ae1c5 0x1313022 0x131190a 0x1310db4 0x1310ccb 0x22c6879 0x22c693e 0x327a9b 0x1cad 0x1c15)
terminate called throwing an exception(lldb)
do you have any idea what can cause it?
Somewhere in your code (it seems to be in AddElementViewController implementation) you are sending message AddPressed: to object of class MainViewController.
The call stack and crash error says that there are no method AddPressed: in class MainViewController.
Try to find all places where you are calling AddPressed: (first of all check loadView, viewDidLoad, viewWillAppear, viewDidAppear, init of AddElementViewController class) and check the type of receiver.

App crashes with [sender tag]

I have a button within interface builder that has a '0' tag on it. The button has a method linked to it called -(IBAction) doTest:(id)sender.
I have the doTest method within my .m file as shown below:
-(IBAction) doTest:(id)sender
{
int currentSelection= [sender tag];
if (currentSelection == 0)
{
// do something
}
}
However my app crashes with the following error message and I have no idea why. Any help would be appreciated. Thanks.
[groceryapp doTest]: unrecognized selector sent to instance 0xc29c00
2012-03-04 20:26:10.155 groceries[4627:707] ***
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[grocery doTest]: unrecognized selector sent to instance 0xc29c00'
Wrong message.
doTest vs doTest: