Request:
- (void) getMyImageWithContestOfFace{
currentApiCall = getMyImageFb;
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"SELECT pic FROM user WHERE uid=me()",#"query",
nil];
AppDelegate *delegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];
[[delegate facebook] requestWithMethodName:#"fql.query"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
}
Parsing:
...
case getMyImageFb:{
flag = TRUE;
imageWithFace = [[UIImage alloc] init];
imageWithFace = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[result objectForKey:#"pic"]]]];
}
break;
...
When i call it i catch very strange exeption:
*2011-11-10 00:30:30.661 FaceGraph[1699:f803] I have some information
2011-11-10 00:30:30.664 FaceGraph[1699:f803] -[__NSArrayM objectForKey:]: unrecognized selector sent to instance 0x6d3d470
2011-11-10 00:30:30.666 FaceGraph[1699:f803] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM objectForKey:]: unrecognized selector sent to instance 0x6d3d470'
First throw call stack:
(0x15d9052 0x176ad0a 0x15daced 0x153ff00 0x153fce2 0x254db 0xb6d6 0xbcf7 0xc9ba59 0xc99e94 0xc9aeb7 0xc99e4f 0xc99fd5 0xbdef6a 0x3b8bbbd 0x3c585ea 0x3b82298 0x3c5816b 0x3b82137 0x15ad97f 0x1510b73 0x1510454 0x150fdb4 0x150fccb 0x14c2879 0x14c293e 0x2a6a9b 0x2332 0x22a5)
terminate called throwing an exceptionsharedlibrary apply-load-rules all
Current language: auto; currently objective-c
No idea why. The most strange that i did it before ABSOLUTELY the same, and it worked fine.
I can't find the difference between my old projects and current. Maybe somebody have the same problem?? If you need more code - ask for it.
thanks
Well, the exception seems to be quite clear: result is probably an array and not a dictionary.
PS: The line imageWithFace = [[UIImage alloc] init]; is totally superfluous given the line that follows it. You should remove it.
I forgot to add:
if ([result isKindOfClass:[NSArray class]]){
result = [result objectAtIndex:0];
}
in result-parsing function.
Related
Im writing this app in objective c (Xcode).
when i use a method in the first time everything goes well, but when i use it the second time it gives me an error.
I tried to debug it and the error goes in the method add tutor in the line if([tutor.userName isEqualToString:userName])
this is the error:
-[__NSCFConstantString userName]: unrecognized selector sent to
instance 0xad14c 2016-02-26 20:10:44.043 project[1258:35474] ***
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[__NSCFConstantString
userName]: unrecognized selector sent to instance 0xad14c'
this is my code:
- (IBAction)addToFavorite:(id)sender {
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSString * userName = delegate.delegateStr;
Student * student = [[Model instance]getStudentByUserName:userName];
[student addTutor:self.tutor.userName];
UIStoryboard* sb = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
FavoritesTableViewController * ftvc = [sb instantiateViewControllerWithIdentifier:#"favoritesTableViewController"];
ftvc.favTutors = student.favTutors;
[[NSNotificationCenter defaultCenter] postNotificationName:#"RefreshTable" object:nil userInfo:nil];
}
-(void)addTutor:(NSString*)userName {
BOOL check = YES;
for (Tutor * tutor in self.favTutors) {
if([tutor.userName isEqualToString:userName])
check = NO;
}
if(check)
[self.favTutors addObject:userName];
}
Please help!!
Thanks.
That's failing because you are adding username in your favTutors array instead of objects of Tutor. So when you add first object and then next time your enumerate through self.favTutors you actually have a string object which will not respond to username property.
problem is here at the line i added comment. you are adding an NSString to objects full of Tutor objects. and in second call of this method, in for loop, tutor is actually an NSString and you are trying to call tutor.userName and it doesnt exist in NSString object.
-(void)addTutor:(NSString*)userName {
BOOL check = YES;
for (Tutor * tutor in self.favTutors) {
if([tutor.userName isEqualToString:userName])
check = NO;
}
if(check)
[self.favTutors addObject:userName]; //problem here!!!!
}
My advice is to create tutor object and add it to your array.
-(void)addTutor:(NSString*)userName {
BOOL check = YES;
for (Tutor * tutor in self.favTutors) {
if([tutor.userName isEqualToString:userName])
check = NO;
}
if(check)
{
// create Tutor object and add it to array dont add NSString directly
}
}
I'm adding Google Admob Fullscreen ads
m_interstitial = [[GADInterstitial alloc] initWithAdUnitID:ADMOB_FS_ID]; // crash here!!!
m_interstitial.delegate = self;
GADRequest* request = [GADRequest request];
request.testDevices = #[ #"XXXXXXXXXXXXXXXXXXXXXXXxxx" ];
[m_interstitial loadRequest:request];
But the app is crash at the init line.
I'm using the Admob ios sdk 7.3.1.
The crash report is below
2015-06-03 00:22:17.077 XXX[17213:4624660] -[GADInterstitialViewController setSlot:]: unrecognized selector sent to instance 0x14e4b6f0
2015-06-03 00:22:17.079 XXX[17213:4624660] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GADInterstitialViewController setSlot:]: unrecognized selector sent to instance 0x14e4b6f0'
*** First throw call stack:
(0x29e9a5a7 0x37a80c77 0x29e9fa6d 0x29e9d949 0x29dceb68 0x1dc9f4 0x19b8b4 0xd3923 0xe488d 0x2d3b437b 0x2d418553 0x2d4184dd 0x2d3945e7 0x29e61275 0x29e5e959 0x29e5ed5b 0x29dabb51 0x29dab963 0x312ea1a9 0x2d3fdc91 0x102011 0x38029aaf)
libc++abi.dylib: terminating with uncaught exception of type NSException
Whats the matter?
EDIT: My whole code is below
in AppDelegate.m
- (void)showNag
{
// GAD full
// m_interstitial = [[GADInterstitial alloc] initWithAdUnitID:ADMOB_FS_ID];
m_interstitial = [[GADInterstitial alloc] init];
m_interstitial.adUnitID = ADMOB_FS_ID;
m_interstitial.delegate = self;
GADRequest* request = [GADRequest request];
request.testDevices = #[ #"251a8278d43c4c1468ce2d807a0ccc72" ];
[m_interstitial loadRequest:request];
}
viewcontroller.m
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
AppDelegate* delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
[delegate showNag];
}
I got it. I had the named GADViewController.h/m files. They made conflict with the GAD framework. The framework also has the same named files. I renamed my files and it works now.
I'm working on an iOS app and I've encountered a problem during testing: the app crashes when I try to enter my next ViewController and I get these messages:
2014-06-29 14:22:46.674 IOS2 Practica[55472:60b] -[Logger login:]: unrecognized selector sent to instance 0x9242230
2014-06-29 14:22:46.679 IOS2 Practica[55472:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Logger login:]: unrecognized selector sent to instance 0x9242230'
From other cases I've looked up, it might be possible that something happens when I attempt to use "segue" to switch to the next ViewController but I can't pinpoint the exact source.
I append the code segment where I define the segue in my main View Controller:
- (void)logger:(id)sender {
NSString *user = self.username.text;
NSString *pass = self.password.text;
NSString * urlBase = #"http://www.v2msoft.com/clientes/lasalle/curs-ios/login.php?username=lluis&password=seguro";
[JSONHTTPClient getJSONFromURLWithString:urlBase completion:^(id json,JSONModelError *err){
JsonUser * user = [[JsonUser alloc]initWithDictionary:json error:nil];
if(user.succeed) {
self.user_id = user.user_id;
[self performSegueWithIdentifier:#"Login" sender:self];
} else {
NSLog(#"error");
}
}];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if (_username.text.length == 0 || _password.text.length == 0) {
[[[UIAlertView alloc] initWithTitle:#"Error"
message:#"Algun dels camps és incorrecte o està buit!"
delegate:self
cancelButtonTitle:#"Cancel"
otherButtonTitles:nil, nil]
show];
} else {
Supermarket * supermercat = segue.destinationViewController;
supermercat.user_id = self.user_id;
}
}
Thank you in advance for any insight on this topic.
Somewhere in your code (not the bit you posted), you should be calling a login: method on a Logger instance. That method is not defined in Logger and that is why the app crashes.
Pay attention to the : at the end of Login:: possibly you have defined a login method (which does not take any argument), but you are calling it with an argument. Or maybe you would have liked to call logger:.
You can try 2 things out: either you find out where the login: method is called (some button bound to it in Storyboard?) or you rename logger: into login:.
I am using BlackRaccoon to download a file from FTP server. Following is the code:
- (IBAction)download:(id)sender {
downloadData = [NSMutableData dataWithCapacity: 1];
downloadFile = [[BRRequestDownload alloc] initWithDelegate: self];
downloadFile.path = #"psnewsletter.pdf";
downloadFile.hostname = #"server";
downloadFile.username = #"user";
downloadFile.password = #"pswd";
[downloadFile start];
}
Its gives following error
2014-02-20 11:48:43.526 BlackHillPrimarySchool[2036:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MainViewController requestFailed:]: unrecognized selector sent to instance 0xcd609f0'
Any help will be appreciated.
requestFailed: is one of the BRRequest delegate method that you must implement in your view controller.
- (void)requestFailed:(BRRequest *)request {
BRRequestError *reqError = request.error;
// check the error, handle as needed.
}
I'm not sure how your code even compiled. This is a required method of the protocol.
i've a piece of code that should get the current location and than put lat and long in a string.
when a new location is found i put it in a NSString
currentLatit = [NSString stringWithFormat:#"%f",newLocation.coordinate.latitude];
currentLongit = [NSString stringWithFormat:#"%f",newLocation.coordinate.longitude];
Than when i press a button i do:
NSLog(currentLatit);
[[UIApplication sharedApplication] openURL:[[NSURL alloc] initWithString: [NSString stringWithFormat:#"http://maps.google.com/maps?saddr=%#,%#&daddr=%#,%#",currentLatit,currentLongit,detailLatitudine,detailLongitudine]]];
but when i execute this, i get this error:
-[__NSCFArray length]: unrecognized selector sent to instance 0x1e1830
2011-11-15 11:29:07.567 Marcovaldo[771:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray length]: unrecognized selector sent to instance 0x1e1830'
*** First throw call stack:
(0x30ae78bf 0x37c8c1e5 0x30aeaacb 0x30ae9945 0x30a44680 0x30a310a9 0x30ac5a97 0x30a42217 0x30a55b8f 0x37b09b9b 0x37b09b3b 0x7253 0x30a41435 0x32a9c9eb 0x32a9c9a7 0x32a9c985 0x32a9c6f5 0x32a9c321 0x32a8f99b 0x30abbb4b 0x30ab9d87 0x30aba0e1 0x30a3d4dd 0x30a3d3a5 0x3366bfed 0x32aaf743 0x2221 0x21e0)
terminate called throwing an exception(gdb)
The error occur on the NSLog execution
realy cannot understand what's wrong whit this simple code...
thanks for any help
-UPDATE-
changed the NSLog as follow:
NSLog(#"%#",currentLatit);
Now the app crash with BAD_ACCESS_EXCEPTION on the NSLog
No, it seems the app crashed at some point other than NSLog. Please clean and build. Or Enable NSZombie and get the exact error location.
Update:
Just do like as following and try.
if( currentLatit )
[currentLatit release];
if( currentLongit )
[currentLongit release];
currentLatit = [[NSString stringWithFormat:#"%f",newLocation.coordinate.latitude] retain];
currentLongit = [[NSString stringWithFormat:#"%f",newLocation.coordinate.longitude] retain];