AFNetworking -[_NSInlineData URL]: unrecognized selector sent to instance - objective-c

I'm using AFNetworking to connect to WebDAV servers for our iPad app (Easy Annotate).
Most functions and servers work correctly.
However, when creating a directory on one of the test servers, the app terminates with the following message:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_NSInlineData URL]: unrecognized selector sent to instance 0x17cc88a0'
Crash location:
AFWebDAVManager.m
- (void)createDirectoryAtURLString:(NSString *)URLString
withIntermediateDirectories:(BOOL)createIntermediateDirectories
completionHandler:(void (^)(NSURL *directoryURL, NSError *error))completionHandler
{
__weak __typeof(self) weakself = self;
[self MKCOL:URLString success:^(__unused AFHTTPRequestOperation *operation, NSURLResponse *response) {
if (completionHandler) {
if([response.class.description isEqualToString:#"_NSZeroData"]) {
completionHandler(nil, nil);
}
else {
completionHandler([response URL], nil); <-- CRASH !!!
}
}
} ...
'response' (see above) is of type _NSInlineData with value:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>
I've found similar threads, which suggest adding $(inherited) to the 'other linker flags'. This did not solve the issue (or I made a mistake ;))
Any ideas what might cause this crash?

We just had the same issue, it's a typo in the code.
It should be completionHandler([operation.response URL], nil);
Best,
Thomas

Related

Gimbal Geofence monitoring crashing NSInvalidArgumentException -[NSURL initFileURLWithPath:]

After integrating Gimbal FYX beacon discovery I tried to add Geofence monitoring as well. I've follow the guides closely and re-written the code several times, ending up with the same crash and error message:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSURL initFileURLWithPath:]: nil string parameter'
Nowhere in my code am I accessing any files or creating any NSObjects from initWithContentsOfFile: methods!
My Code:
[connector enableFromViewController:viewController success:^{
NSLog(#"ContextCoreConnector ACTIVATED!");
self.placeConnector = [[QLContextPlaceConnector alloc] init];
self.placeConnector.delegate = self;
[self.placeConnector monitorPlacesWhenAllowed];
[self.placeConnector monitorPlacesInBackground];
if ([self.geofenceDelegate respondsToSelector:#selector(startedGeofenceMonitoring)]) {
[self.geofenceDelegate startedGeofenceMonitoring];
}
} failure:^(NSError *error) {
NSLog(#"ContextCoreConnector FAILED!\n%#",error.localizedDescription);
if ([self.geofenceDelegate respondsToSelector:#selector(startedGeofenceMonitoring)]) {
[self.geofenceDelegate startedGeofenceMonitoring];
}
}];
Turns out in the ContextLocation.framework there is a folder called "Resources" and there is a DataModels.bundle file that you need to check the 'Target Membership' in the right side panel of XCode. I had checked all my frameworks as the guides suggested but not that Resources folder.

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.

Facebook sdk iOS logout error

I'm currently working with the new Facebook SDK and I have a very strange problem. I have a viewcontroller, called FacebookExplorerTableViewController and in my viewdidload I have the following piece of code:
if(appDelegate.session.isOpen)
{
[self receiveAlbums];
}
else
{
appDelegate.session = [[FBSession alloc] init];
appDelegate.session = [FBSession sessionOpenWithPermissions:nil completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
NSLog(#"opened session");
if(!error) [self receiveAlbums];
else NSLog(#"error: %#",error);
}];
}
When I'm running it, everything's fine. However, I have another viewcontroller, named SharingSettingsTableViewController where I have the option to logout:
[appDelegate.session closeAndClearTokenInformation];
When I'm trying to logout, I get a xCode crash:
2012-08-09 21:29:19.683 My Albums[2197:17903] opened session
2012-08-09 21:29:19.684 My Albums[2197:17903] requesting albums
2012-08-09 21:29:19.695 My Albums[2197:17903] access token: (null)
2012-08-09 21:29:19.697 My Albums[2197:17903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(0x1b6d022 0x1f56cd6 0x1aac7db 0x1ac4e86 0x757a5 0x754f4 0xa17e2 0x9ef39 0x676f9 0x92c3f1 0x1b6ee99 0x55514e 0x5550e6 0x5fbade 0x5fbfa7 0x5fb266 0x57a3c0 0x57a5e6 0x560dc4 0x554634 0x232eef5 0x1b41195 0x1aa5ff2 0x1aa48da 0x1aa3d84 0x1aa3c9b 0x232d7d8 0x232d88a 0x552626 0x21ed 0x2155)
terminate called throwing an exception
It seems to run my completion block again! The 'requesting albums' in the console is coming from the call to receiveAlbums.
Why does this completion block run again? At the time I go to the Settings view controller, I've already deallocated the FacebookExplorerTableViewController! How can this run and how could I get rid of the error? :)
Thanks in advance!
I've had the same issue. My problem was retaining [FBSession activeSession].accessToken by passing it into a NSDictionary. The easiest solution was to pass a [NSString stringWithFormat:#"%#", [FBSession activeSession].accessToken] instead of straight [FBSession activeSession].accessToken usage.

Posting comment to YouTube with GData ObjC client library fails

I'm trying to implement commenting on YouTube videos with the gdata-objectivec-client library, using the code snippet posted in this thread; copy follows:
- (void)addCommentTitle:(NSString *)commentTitle
text:(NSString *)commentContent
toVideo:(GDataEntryYouTubeVideo *)entry {
GDataComment *commentObj = [entry comment];
GDataFeedLink *feedLink = [commentObj feedLink];
NSURL *feedURL = [feedLink URL];
if (feedURL) {
// fetch the comment feed for the video
GDataServiceGoogleYouTube *service = [self youTubeService];
[service fetchFeedWithURL:feedURL
completionHandler:^(GDataServiceTicket *ticket, GDataFeedBase *commentFeed, NSError *error) {
// callback
//
// insert a new comment into the comment feed
if (error == nil) {
GDataEntryYouTubeComment *newCommentEntry = [GDataEntryYouTubeComment commentEntry];
[newCommentEntry setTitleWithString:commentTitle];
[newCommentEntry setContentWithString:commentContent];
NSURL *postURL = [[commentFeed postLink] URL];
[service fetchEntryByInsertingEntry:newCommentEntry
forFeedURL:postURL
completionHandler:^(GDataServiceTicket *ticket, GDataEntryBase *entry, NSError *error) {
// callback
if (error == nil) {
// succeeded
}
}];
}
}];
}
}
but I always get the following exception:
*** Assertion failure in -[GDataObject setContentStringValue:](), XXXXXXXX/GData/BaseClasses/GDataObject.m:2353
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'GDataEntryYouTubeComment setting undeclared content value'
Luckily enough, I managed to make this go away by adding a new call before the comment contents are set:
GDataEntryYouTubeComment* newCommentEntry = [GDataEntryYouTubeComment commentEntry];
[newCommentEntry addContentValueDeclaration]; // <--- this method does the trick
[newCommentEntry setTitleWithString:commentTitle];
[newCommentEntry setContentStringValue:commentContent];
but it's still not OK as the request now bounces back from the server with this error:
serviceBase:<GDataServiceGoogleYouTube: 0x7a73eb0>
objectFetcher:GTMHTTPFetcher 0x7c75b20 (https://gdata.youtube.com/feeds/api/videos/XXXXXXXXXX/comments)
failedWithStatus:400
data:<errors xmlns='http://schemas.google.com/g/2005'><error><domain>GData</domain><code>ParseException</code><internalReason>[Line 2, Column 514, element entry] No converter for type class java.lang.Void</internalReason></error><error><domain>GData</domain><code>missingConverter</code><internalReason>No converter for type class java.lang.Void</internalReason></error></errors>
Has anyone else run into this issue? Is this an error on my side or Google's side?
Turns out the above code is correct, in my code I misspelled
[newCommentEntry setContentWithString:commentContent];
and used
[newCommentEntry setContentStringValue:commentContent];
instead. Now it works fine.

Fail to catch exception from proxy object under Xcode 3.2.3

I use HessianKit to communicate with server. In the situation of network or server down Hessian will throw exception, so I put every Hessian call in a #try ... #catch block. Everything worked fine until I upgraded Xcode from 3.2.2 to 3.2.3. I wrote the some testing code and found under Xcode 3.2.3, catch exception would be failed if the exception was thrown from a proxy object.
MyProxy.h:
#interface MyProxy : NSProxy {
}
#end
MyProxy.m:
#implementation MyProxy
- (id)init {
return self;
}
- (void)forwardInvocation:(NSInvocation *)invocation {
NSLog(#"Call method %#", NSStringFromSelector([invocation selector]));
[NSException raise:#"MyException" format:#"this is an exception"];
}
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
.....
}
#end
Code using MyProxy:
#try {
MyProxy *p = [[MyProxy alloc] init];
[p doSomething];
[p release];
}
#catch (NSException * e) {
NSLog(#"%#", e);
}
When these code build under xcode 3.2.2, the exception can be catched correctly. But under xcode 3.2.3, the program terminated after output following on the console:
2010-09-08 21:09:29.877 BriefCase[34651:40b] Call method doSomgthing
2010-09-08 21:09:29.879 BriefCase[34651:40b] *** Terminating app due to uncaught exception 'MyException', reason: 'this is an exception'
2010-09-08 21:09:29.880 BriefCase[34651:40b] Stack: (
45955152,
47113004,
45692683,
45692522,
151932,
45426420,
45423090,
9352,
4417860,
4421967,
4447550,
4429047,
4461016,
53399932,
45234332,
45230248,
4420129,
4453234,
8812,
8666
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
What can I do?
I filed a bug with Apple, and the reply is:
It has been determined that this is a known issue, which is currently being investigated by engineering. This issue has been filed in our bug database under the original Bug ID# 7995323.
Maybe your project/target/executable settings have been messed up?
Is the "Enable Objective-C Exceptions" box ticked for your configuration/target/etc?
If it is, maybe you should file a bug with Apple here.