ios 5 AWS SDK S3PutObjectRequest - amazon-s3

I just updated my app to ios5 and the code below (that was working in 4x) is now not working
I thought it was because of the UUID but i changed that and the error stayed the same. The error I am getting is below. Any help is greatly appreciated -- thx
I setup some breakpoints and isolated the error and i think the error is with localPutObjectRequest but after looking at what that line does the error message does not make sense to me.
- (void) updateLocation:(CLLocation*)loc
{
[progressView setProgress:5];
[[LocationManager sharedLocationManager] setDelegate:nil];
uploadPath = [NSString stringWithFormat:#"%#/%#-%f.png", [[UIDevice currentDevice] uniqueIdentifier], [[UIDevice currentDevice] uniqueIdentifier], [[NSDate date] timeIntervalSince1970]];
S3PutObjectRequest *localPutObjectRequest = [[[S3PutObjectRequest alloc] initWithKey:uploadPath inBucket:[NSString stringWithFormat:#"spotted-at"]] autorelease];
localPutObjectRequest.data = UIImagePNGRepresentation([UIImage imageWithData:imageData]);
[localPutObjectRequest setDelegate:self];
[[Constants s3] putObject:localPutObjectRequest];
}
2011-10-23 00:45:39.654 spotted.at[4131:707] -[UIButtonContent length]: unrecognized selector sent to instance 0x2c0130
2011-10-23 00:45:39.656 spotted.at[4131:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIButtonContent length]: unrecognized selector sent to instance 0x2c0130'
*** First throw call stack:
(0x310868bf 0x3822b1e5 0x31089acb 0x31088945 0x30fe3680 0x330e42ef 0x330e4267 0x331d7e51 0x49041 0x4973d 0x352c05df 0x352bff81 0x352ba62f 0x3105ab31 0x3105a15f 0x31059381 0x30fdc4dd 0x30fdc3a5 0x33c0afed 0x3304e743 0x453b 0x3f74)

Judging from your post, the error lies in
[[UIDevice currentDevice] uniqueIdentifier]
The method UIDevice uniqueIdentifier is deprecated in iOS 5 and should not be called. From your code I cant really see what exactly you are trying to do but this post
UIDevice uniqueIdentifier Deprecated - What To Do Now?
should be helpful in overcoming the deprecated method. You should change the deprecated calls and also use the ones listed in the post above. That should do the trick.

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.

NSUserDefaults crashes when adding empty array

I just moved to iOS 8, installed Xcode 6 etc.
This code worked nicely on iOS 7 and 6. It even seems to work on an iPhone 4S with iOS 8 installed. But on iPhones 5 and 5S it crashes. (8.0.0 and 8.0.2 alike)
It does not matter whether the app is build against SDK 7 or 8. It crashes in both cases at the same stage.
The .h file contains:
#property (nonatomic, strong) NSMutableArray* filterBrandsExclude;
from the .m file:
// Following lines just to set the conditions for your understanding:
_filterBrandsExclude = [[NSMutableArray alloc] initWithCapacity:0]; // just creates an empty array.
// As a matter of fact, this array may well be empty and it worked nicely on older iOS versions.
// this line crashes:
[userDefaults setObject:_filterBrandsExclude forKey:#"filterBrandsExclude"];
Error Message:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSKeyValueSlowMutableArray getObjects:range:]: value for key filterBrandsExclude of object 0x17004ae00 is nil'
*** First throw call stack:
(0x1885c6084 0x198bac0e4 0x1885c5fc4 0x18946097c 0x189460a68 0x189460ab0 0x1884c24d0 0x18854be90 0x1884c21c0 0x1884c17e8 0x188627c80 0x188552d9c 0x188551e9c 0x188600290 0x1885ff840 0x1886030e4 0x1893bb750 0x100053e5c 0x1000522a4 0x18cfd65d4 0x18cfdead0 0x18cfdea58 0x18cfd238c 0x1907d1640 0x18857e360 0x18857d468 0x18857ba8c 0x1884a9664 0x1915eb5a4 0x18cdae984 0x1000515f4 0x19921aa08)
libc++abi.dylib: terminating with uncaught exception of type NSException
Any idea is appreciated.
you can manually check
if(self.filterBrandsExclude != nil && self.filterBrandsExclude.count > 0)
[userDefaults setObject:_filterBrandsExclude forKey:#"filterBrandsExclude"];
else
[[NSUserDefaults standardUserDefaults] removeObjectForKey:#"filterBrandsExclude"];
Two things.
In your error it says that the value for the key filterBrandsInclude is nil, but in your question you reference the key filterBrandsExclude. Are you sure you've pinpointed the actual error at this point?
EDIT: Point #2 is invalid.

Objective-C errors after getting the IAP product response

This code is from the Phonegap Code: IAP Plugin. The error happens on the line of the code right after the "sent js". All the elements sent to the function are non-nil except for the last one 'nil'. I even logged them out to make sure they were sent. This code is right out of the plugin (https://github.com/usmart/InAppPurchaseManager-EXAMPLE) and has not been modified except for the logging. In the debugger i saw that none of the objects were nil, so i don't understand why the error is happening.
Here is the error:
[__NSArrayI JSONRepresentation]: unrecognized selector sent to
instance 0xdc542d0
2013-02-13 23:26:17.209 GoblinSlots[4519:707] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'-[__NSArrayI JSONRepresentation]: unrecognized selector sent to
instance 0xdc542d0'
here is the code:
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse: (SKProductsResponse *)response
{
NSLog(#"got iap product response");
for (SKProduct *product in response.products) {
NSLog(#"sending js for %#", product.productIdentifier);
NSLog(#" title %#", product.localizedTitle );
NSLog(#" desc%# - %#", product.localizedDescription, product.localizedPrice );
NSArray *callbackArgs = [NSArray arrayWithObjects:
NILABLE(product.productIdentifier),
NILABLE(product.localizedTitle),
NILABLE(product.localizedDescription),
NILABLE(product.localizedPrice),
nil ];
NSLog(#"sent js");
NSString *js = [NSString stringWithFormat:#"%#.apply(plugins.inAppPurchaseManager, %#)", successCallback, [callbackArgs JSONSerialize]];
NSLog(#"js: %#", js);
[command writeJavascript: js];
}
All the stuff to do JSON serialization seems to be already included with the Cordova plugins.
There's no need to download and install yet another JSON library.(a)
It appears that PhoneGap is in the process of switching from SBJson to JSONKit.(b)
PhoneGap is also in the process of changing all the JSON methods to use a "cdvjk_" prefix. (c)
As far as I can tell, something didn't quite go right during those changes.
What I did was edit the file Plugins/InAppPurchaseManager.m , where I made these changes:
Add the line
#import <Cordova/CDVJSON.h>
Replace the line
return [self respondsToSelector:#selector(cdvjk_JSONString)] ? [self cdvjk_JSONString] : [self cdvjk_JSONRepresentation];
with
return [self JSONString];
. (What's the right way to push this or a better bugfix back to the nice PhoneGap people?)
JSONRepresentation is a category that SBJson adds so you have to include SBJson.h in the class that uses it.

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

report which method caused my NSException?

I am using Flurry Analytics which reports my app crashes, works great except I don't know which method caused the crash.
I am catching the uncaught exceptions like this:
{
[FlurryAnalytics logError:#"Uncaught" message:[NSString stringWithFormat:#"Crash! %#", [[UIDevice currentDevice] uniqueIdentifier]] exception:exception];
}
If I could only see which method this would be absolutely perfect. Thoughts?
Use
NSlog(#"function that crashed %s",__FUNCTION__);
This is an extension to the compiler and works fine.
UPDATE
to get the complete call stack from the current thread use:
[NSThread callStackSymbols]
which gives you the call stack as NSString.