AVAssetWriter invalid URL for writing - objective-c

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

Related

why crash this code at boundingRectWithSize?

- (CGSize)sizeOfLabel:(UILabel *)label withText:(NSString *)text {
CGSize maximumLabelSize = CGSizeMake(308,9999);
UIFont *font=[UIFont systemFontOfSize:14];
CGRect textRect = [text boundingRectWithSize:maximumLabelSize options:NSStringDrawingUsesLineFragmentOrigin attributes:#{NSFontAttributeName:font} context:nil]; // CRASH HERE
return textRect.size;
}
**the error message is:**
2014-06-16 14:55:07.783 OrgBeac[2931:60b] -[Message boundingRectWithSize:options:attributes:context:]: unrecognized selector sent to instance 0x17557a70
2014-06-16 14:55:07.787 OrgBeac[2931:60b] \*\*\* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Message boundingRectWithSize:options:attributes:context:]: unrecognized selector sent to instance 0x17557a70'
\*\*\* First throw call stack:
(0x2e6f4fd3 0x38f6dccf 0x2e6f8967 0x2e6f7253 0x2e6f84f8 0x575d5 0x579e7 0x31020a2b 0x30fe569f 0x30fe73fd 0x30fe7351 0x30fe6f45 0x56f37 0x2f0e56d1 0x39324cef 0x393222ad 0x39321319 0x2f0e3cb9 0x2f0e3f41 0x2f0e40b7 0x2f0e41b5 0x5674d 0x2f033fc3 0x2f033f07 0x2f033e21 0x2e35b0e7 0x2e359cf7 0x2e628941 0x2e2f16bb 0x2e2f1579 0x2e2f140d 0x2e6c025b 0x2e6bf72b 0x2e6bdf1f 0x2e628f0f 0x2e628cf3 0x33581663 0x30f7416d 0x55283 0x3947aab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
The object text that you are passing in needs to be an NSString but it is a Message object.
I'm guessing that wherever you are calling this from you are doing something like...
[someObject sizeOfLabel:myLabel withText:message];
When in fact what you meant is...
[someObject sizeOfLabel:myLabel withText:message.text];

assigning values in NSArrays

Objective C gives me a run-time error for the indicated line of code
-(void) play: (int)i at: (int)j {
if ([self.board[i][j] isEqualToString:#""]){
if (xplays) {
self.board[i][j] = #"x"; //<-----HERE
}
else
self.board[i][j] = #"x";
}
xplays = !xplays;
}
board is a property. The error message is
[__NSArrayI replaceObjectAtIndex:withObject:]: unrecognized selector sent to instance 0x7123120
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI replaceObjectAtIndex:withObject:]: unrecognized selector sent to instance 0x7123120'
Do I need to use C-arrays for this kind of assignment?
You should be using an NSMutableArray.

NSKeyedUnarchiver unarchiveObjectWithData crashes - No way to catch the exception?

I have the following code:
#try {
NSSet *set = [NSKeyedUnarchiver unarchiveObjectWithData:mData];
}
#catch (NSException *exception) {
// Use default data
}
At some point it seems that I wasn't archiving properly and mData is corrupted.
This gives me the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** -[NSKeyedUnarchiver initForReadingWithData:]:
incomprehensible archive (0x14, 0xffffff9a, 0xffffffd0, 0x1d, 0x9, 0x3d, 0x43, 0x3)'
*** Call stack at first throw:
If a try/catch block does not work, how am I supposed to check for an exception here? Shouldn't it be working?
Thank you.
I don't think the try-catch code wasn't working. The log says "uncaught exception" so this error happens somewhere else in your code.

Error saving to iOS keychain using KeychainItemWrapper

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.

Why am I receiving an error message when attempting NSScanner to use in a NSString statement?

I would like to know why I get an error message
Thread 1: Program received signal: "SIGABRT")
When I use this line of code:
NSScanner *userEntered = [[NSScanner alloc] scannerWithString:temp];
The error is:
2011-04-18 02:06:11.995 XXX[25929:207] -[NSConcreteScanner scannerWithString:]: unrecognized selector sent to instance 0x6816bc0
2011-04-18 02:06:11.999 XXX[25929:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteScanner scannerWithString:]: unrecognized selector sent to instance 0x6816bc0'
Thank you.
+scannerWithString is a class method and should be used the following way:
NSScanner *userEntered = [NSScanner scannerWithString:temp];