Error saving to iOS keychain using KeychainItemWrapper - objective-c

I get an error every time I try to store data into the keychain
The error comes from the dictionaryToSecItemFormat method at these lines
NSString *passwordString = [dictionaryToConvert objectForKey:(id)kSecValueData];
[returnDictionary setObject:[passwordString dataUsingEncoding:NSUTF8StringEncoding] forKey:(id)kSecValueData]'
The error is
I'm calling the KeychainItemWrapper methods like this
KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:#"credentials" accessGroup:nil];
[keychain setObject:username forKey:kSecAttrAccount];
[keychain release];
The error is
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'-[NSConcreteData dataUsingEncoding:]: unrecognized selector sent to instance"

dataUsingEncoding is a method from the NSString class, make username a NSString.

Related

Problems passing data between different classes with a method

I have this in a class:
NSString *globalMidiData = #"30a0a00\n";
switch (IndicatorCheckNXT) {
case 1:
[testRobot checkTestRobot:globalMidiData];
break;
default:
break;
}
And in another class I have this:
-(void) checkTestRobot: (NSString *)midiDataGlobal{
bool pressed;
bool pressed2;
NSString *miawmiaw =[NSString alloc];
miawmiaw=midiDataGlobal;
}
And I got this message:
-[AppDelegate checkTestRobot:]: unrecognized selector sent to instance 0x18acb0
2012-11-23 20:45:31.755 Exemple1[477:707] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppDelegate checkTestRobot:]: unrecognized selector sent to instance 0x18acb0'
What I am doing wrong?
Obviously you send checkTestRobot to the wrong object. testRobot seems to point to the AppDelegate and not to an instance of your class.
Also you should replace this:
NSString *miawmiaw =[NSString alloc];
miawmiaw=midiDataGlobal;
with:
NSString *miawmiaw = [midiDataGlobal copy];

AVAssetWriter invalid URL for writing

I'm getting this error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVAssetWriter initWithURL:fileType:error:] invalid parameter not satisfying: [outputURL isFileURL]'
On this line:
AVAssetWriter * assetWriter = [[AVAssetWriter alloc] initWithURL:videoURL
fileType: AVFileTypeMPEG4
error: &movieError];
Where videoURL logs as:
/var/mobile/Applications/A032EEA6-C83D-49DA-B118-E4E4B9F41C7F/Documents/videoForSegmentNumber1.mp4
the line before this is called.
I've also tested against isFileURL myself and its returning NO. What is required to be a valid fileURL?
Use
+ (id)fileURLWithPath:(NSString *)path
instead of
+ (id)URLWithString:(NSString *)URLString

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...

-[__NSCFNumber isEqualToString] error

I'm getting this crash, but, in my code I am using a string. I've been working on this one piece of code for 2 hours now and I just can't see what I'm missing! Any ideas?
NSString *codeR = [NSString stringWithFormat:#"%#", [[object objectForKey:#"code"] stringValue]];
if([codeR isEqualToString:#"200"])
Error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x181cf0'
I would be very grateful input, this is confusing the hell out of me!
Thanks.
Get rid of silly redundancy, see what happens.
NSString *codeR = [[object objectForKey:#"code"] stringValue];
// mysterious missing code
if ([coreR isEqualToString:#"200"]) // etc
Also, are you sure the error is raised from the if statement you posted? It could be coming from elsewhere.
NSString *codeR = [[object objectForKey:#"code"] stringValue];
if ([codeR isEqualToString:#"200"])
{
// Do stuff...
}

Objective C: Error when trying to initialize instance of CLLocation

I am hitting an error (program crashed) when it hits the following code
CLLocation *userLoc = [[CLLocation alloc] initWithCoordinate:locationManager.location.coordinate];
I tried to replace the argument with the following and I get the same error as well
CLLocation *userLoc = [[CLLocation alloc] initWithCoordinate:mapView.userLocation.coordinate];
Can anyone advise me on what should be the correct argument to use here for the user's current location?
Thanks!
Zhen
Stacktrace:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CLLocation initWithCoordinate:]: unrecognized selector sent to instance 0x1e0620'
According to the documentation, CLLocation does not have an initializer called initWithCoordinate:. Use one of the following:
initWithLatitude:longitude:
initWithCoordinate:altitude:horizontalAccuracy:verticalAccuracy:timestamp:
initWithCoordinate:altitude:horizontalAccuracy:verticalAccuracy:course:speed:timestamp: