Parsing JSON and sometimes getting number instead of a string - ios

I have an iPhone app which fetches user information (first name, last name, city) in JSON format from different social networks.
This works mostly well, but one of the social networks returns the city as a number instead of a string (actually I should made one more REST call to map this number to a city name... but for now I just want to display the number).
And when I try to display that number in a UILabel I get the exception (here fullscreen):
2014-02-15 11:24:16.194 MyAuth[8872:a0b] -[__NSCFNumber length]: unrecognized selector sent to instance 0xb074f90
2014-02-15 11:24:16.203 MyAuth[8872:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0xb074f90'
*** First throw call stack:
(
0 CoreFoundation 0x01bb15e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x019348b6 objc_exception_throw + 44
2 CoreFoundation 0x01c4e903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01ba190b ___forwarding___ + 1019
4 CoreFoundation 0x01ba14ee _CF_forwarding_prep_0 + 14
5 Foundation 0x015798ed -[NSConcreteMutableAttributedString replaceCharactersInRange:withString:] + 39
6 Foundation 0x0157a55a -[NSConcreteMutableAttributedString initWithString:attributes:] + 293
7 UIKit 0x0084fbc6 -[UILabel _setText:] + 97
8 UIKit 0x0084fd84 -[UILabel setText:] + 40
9 MyAuth 0x0000a296 -[UserViewController viewDidLoad] + 678
10 UIKit 0x007b6318 -[UIViewController loadViewIfRequired] + 696
11 UIKit 0x007b65b4 -[UIViewController view] + 35
12 UIKit 0x007d03e2 -[UINavigationController _startCustomTransition:] + 778
13 UIKit 0x007dd0c7 -[UINavigationController _startDeferredTransitionIfNeeded:] + 688
14 UIKit 0x007ddcb9 -[UINavigationController __viewWillLayoutSubviews] + 57
15 UIKit 0x00917181 -[UILayoutContainerView layoutSubviews] + 213
16 UIKit 0x0070d267 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
17 libobjc.A.dylib 0x0194681f -[NSObject performSelector:withObject:] + 70
18 QuartzCore 0x054e12ea -[CALayer layoutSublayers] + 148
19 QuartzCore 0x054d50d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
20 QuartzCore 0x054d4f40 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
21 QuartzCore 0x0543cae6 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
22 QuartzCore 0x0543de71 _ZN2CA11Transaction6commitEv + 393
23 QuartzCore 0x0543e544 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
24 CoreFoundation 0x01b794ce __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
25 CoreFoundation 0x01b7941f __CFRunLoopDoObservers + 399
26 CoreFoundation 0x01b57344 __CFRunLoopRun + 1076
27 CoreFoundation 0x01b56ac3 CFRunLoopRunSpecific + 467
28 CoreFoundation 0x01b568db CFRunLoopRunInMode + 123
29 GraphicsServices 0x031a09e2 GSEventRunModal + 192
30 GraphicsServices 0x031a0809 GSEventRun + 104
31 UIKit 0x006a2d3b UIApplicationMain + 1225
32 MyAuth 0x0000ab7d main + 141
33 libdyld.dylib 0x02518725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
So I go to my JSON parsing code:
- (User*)createUserFromJson:(id)json
{
if (![json isKindOfClass:[NSDictionary class]]) {
NSLog(#"Parsing response failed");
return nil;
}
NSDictionary *dict = json[#"response"][0];
User *user = [[User alloc] init];
user.key = kVK;
user.userId = dict[#"uid"];
user.firstName = dict[#"first_name"];
user.lastName = dict[#"last_name"];
user.city = dict[#"city"]; // THE PROBLEMATIC LINE
user.avatar = dict[#"photo_big"];
user.female = (2 == [dict[#"female"] intValue]);
return user;
}
and try to change it to:
user.city = [NSString stringWithFormat:#"%d", dict[#"city"]];
but then I get the compile-time warning (here fullscreen):
Format specifies type 'int' but the argument has type 'id'
So my question is how to solve this issue cleanly (w/o Xcode warnings) and robust (when fetched JSON data happens to be a string)?

The fastest solution is:
[NSString stringWithFormat:#"%#", dict[#"city"]];
which will take the description of the string or the number and convert that into a string.
In the future you may want to use:
if ([1dict[#"city"] isKindOfClass:[NSNumber class]]) { ...
to check what you have received and work with it specifically. i.e. to do your lookup and to not use stringWithFormat: when you actually already have a string (because it's inefficient).

Related

App crashes while using NSURL URLWithString in a "for" loop

Here's my code,
for (int i=0; i<=[selfLinksArray count]; i++) {
NSString *temp = selfLinksArray[i];
NSURL *tempURL = [NSURL URLWithString:temp ];
NSLog(#"NSURL:%#",tempURL);
NSData *tempData = [NSData dataWithContentsOfURL:tempURL];
NSError *error = nil;
NSDictionary *tempDict = [NSJSONSerialization JSONObjectWithData:tempData options:0 error:&error];
NSDictionary *volumeInfoDict = [tempDict objectForKey:#"volumeInfo"];
titleArray[i]=[volumeInfoDict objectForKey:#"title"];
}
Xcode shows me this error
[__NSArrayI length]: unrecognized selector sent to instance 0x7fdf334f0bc0
2016-01-19 16:12:34.937 BookFindr[7775:449799] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI length]: unrecognized selector sent to instance 0x7fdf334f0bc0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010f34be65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010edc4deb objc_exception_throw + 48
2 CoreFoundation 0x000000010f35448d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010f2a190a ___forwarding___ + 970
4 CoreFoundation 0x000000010f2a14b8 _CF_forwarding_prep_0 + 120
5 CoreFoundation 0x000000010f32e261 _CFURLCreateWithURLString + 81
6 Foundation 0x000000010e97a465 -[NSURL(NSURL) initWithString:relativeToURL:] + 349
7 Foundation 0x000000010e97a2e2 +[NSURL(NSURL) URLWithString:relativeToURL:] + 59
8 BookFindr 0x000000010e8bf9ab -[tabResTableViewController viewDidLoad] + 219
9 UIKit 0x000000010f88ef98 -[UIViewController loadViewIfRequired] + 1198
10 UIKit 0x000000010f894f4f -[UIViewController __viewWillAppear:] + 120
11 UIKit 0x000000010f8c4e44 -[UINavigationController _startCustomTransition:] + 1203
12 UIKit 0x000000010f8d523f -[UINavigationController _startDeferredTransitionIfNeeded:] + 712
13 UIKit 0x000000010f8d63af -[UINavigationController __viewWillLayoutSubviews] + 57
14 UIKit 0x000000010fa7cff7 -[UILayoutContainerView layoutSubviews] + 248
15 UIKit 0x000000010f7af4a3 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
16 QuartzCore 0x000000011327b59a -[CALayer layoutSublayers] + 146
17 QuartzCore 0x000000011326fe70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
18 QuartzCore 0x000000011326fcee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
19 QuartzCore 0x0000000113264475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
20 QuartzCore 0x0000000113291c0a _ZN2CA11Transaction6commitEv + 486
21 UIKit 0x000000010f6f2f7c _UIApplicationHandleEventQueue + 7329
22 CoreFoundation 0x000000010f277a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
23 CoreFoundation 0x000000010f26d95c __CFRunLoopDoSources0 + 556
24 CoreFoundation 0x000000010f26ce13 __CFRunLoopRun + 867
25 CoreFoundation 0x000000010f26c828 CFRunLoopRunSpecific + 488
26 GraphicsServices 0x0000000112b08ad2 GSEventRunModal + 161
27 UIKit 0x000000010f6f8610 UIApplicationMain + 171
28 BookFindr 0x000000010e8c101f main + 111
29 libdyld.dylib 0x0000000111a8792d start + 1
30 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
I have imported selfLinkArray from another viewController. I want to fetch various titles which are present in VolumeInfo dictionary. This dictionary is present in each individual link in selfLinksArray. Please help me with this error. Thanks in Advance.
Let's analyze your error and your backtrace :
-[__NSArrayI length]: unrecognized selector sent to instance 0x7fdf334f0bc0'
The issue is written here: the length method is called on an NSArray object.
Wait, this method is not even written in this sample! Don't worry, let's analyze it.
6 Foundation 0x000000010e97a465
-[NSURL(NSURL) initWithString:relativeToURL:] + 349
7 Foundation 0x000000010e97a2e2 +[NSURL(NSURL) URLWithString:relativeToURL:]
The crash log indicates that the crash occurs when you try to init the NSURL object. The only parameter of this init method is a NSString object. But are we sure that temp is really a NSString object ?
This variable is casted without checking if it's really an NSString object. It can be anthing, for example... the NSArray which receive a call to the length method. Also, this method is existing for a NSString object, so the unrecognizer selector error look totally related.
Where do you we call length on this NSString object ? My guess is, according to the backtrace, that URLWithString: call this method to check the NSString length in order to initialize properly the NSURL object.

JSON Thumbnail image in Custom Table View Cell

I really get tired of trying to fix this so I think I need some help. I am filling each Cells of my iOS from an API which I successfully parsed (Can retrieve simple things such as texts, or numbers with no problem)
But when I tried to set the images for the thumbnails I am having some errors.
This is my code:
NSString *imageUrl = [tempDictionary valueForKeyPath:#"files.url_thumb"];
NSURL *url = [NSURL URLWithString:imageUrl];
NSData *imageData = [NSData dataWithContentsOfURL:url];
UIImage *thumbNailImage = [UIImage imageWithData:imageData];
dispatch_async(dispatch_get_main_queue(), ^{
[cell.ThumbImage setImage:thumbNailImage];
});
and this are the nightmares in my console:
2015-04-08 13:14:26.450 WebTableView[4976:173380] -[__NSArrayI length]:
unrecognized selector sent to instance 0x79e18b90
2015-04-08 13:14:26.509 WebTableView[4976:173380] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI length]: unrecognized selector sent to instance 0x79e18b90'
*** First throw call stack:
(
0 CoreFoundation 0x036c9466 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x03352a97 objc_exception_throw + 44
2 CoreFoundation 0x036d12c5 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
3 CoreFoundation 0x03619bc7 ___forwarding___ + 1047
4 CoreFoundation 0x0361978e _CF_forwarding_prep_0 + 14
5 CoreFoundation 0x035836cf CFStringGetLength + 143
6 CoreFoundation 0x036a9c8d _CFURLCreateWithURLString + 77
7 CoreFoundation 0x035952d3 CFURLCreateWithString + 35
8 Foundation 0x02f17999 -[NSURL(NSURL) initWithString:relativeToURL:] + 371
9 Foundation 0x02f17807 +[NSURL(NSURL) URLWithString:relativeToURL:] + 80
10 Foundation 0x02f177b1 +[NSURL(NSURL) URLWithString:] + 48
11 WebTableView 0x00111a8b -[TableViewController tableView:cellForRowAtIndexPath:] + 571
12 UIKit 0x01c26c9c -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 473
13 UIKit 0x01c26d7e -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 77
14 UIKit 0x01c0054b -[UITableView _updateVisibleCellsNow:isRecursive:] + 3034
15 UIKit 0x01c1aeb1 -[UITableView layoutSubviews] + 222
16 UIKit 0x01b907b1 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 608
17 libobjc.A.dylib 0x03368771 -[NSObject performSelector:withObject:] + 70
18 QuartzCore 0x009421cf -[CALayer layoutSublayers] + 152
19 QuartzCore 0x00936055 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 397
20 QuartzCore 0x00935eb0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
21 QuartzCore 0x008941b6 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 284
22 QuartzCore 0x0089558a _ZN2CA11Transaction6commitEv + 392
23 QuartzCore 0x00895c56 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
24 CoreFoundation 0x035ec18e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
25 CoreFoundation 0x035ec0d0 __CFRunLoopDoObservers + 400
26 CoreFoundation 0x035e1b0a __CFRunLoopRun + 1226
27 CoreFoundation 0x035e137b CFRunLoopRunSpecific + 443
28 CoreFoundation 0x035e11ab CFRunLoopRunInMode + 123
29 GraphicsServices 0x04b3d2c1 GSEventRunModal + 192
30 GraphicsServices 0x04b3d0fe GSEventRun + 104
31 UIKit 0x01b049b6 UIApplicationMain + 1526
32 WebTableView 0x000dd6cd main + 141
33 libdyld.dylib 0x03e94ac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I think valueForKeyPath: returning an array of objects. Try logging imageUrl and check what you are getting.
If you are confident that there would be only one url then you can try this -
NSString *imageUrl = [[tempDictionary valueForKeyPath:#"files.url_thumb"] lastObject];
Else try something like this -
valueForKey:#"files"] valueForKey:#"url_thumb]

App crashing with error: -[NSNull length]: unrecognized selector sent to instance

This line [self.label setFont:[MyUtilityClass fontWithSize:13.0f]]; of code is giving me the -[NSNull length]: crash. label as many of you guys can guess is a UILabel. The only logical explanation I can think of is UILabel text is null. I will post my utility class below just in case it helps.
MyUtilityClass
+ (UIFont *) fontWithSize : (CGFloat) size
{
UIFont *font = [UIFont fontWithName:#"Roboto-Regular" size:size];
return font;
}
edit: This is the error message I've received. I can copy and paste the raw data if you need me to. This is a crash a user received according to crashlytics.
Fatal Exception: NSInvalidArgumentException
-[NSNull length]: unrecognized selector sent to instance 0x378e23f0
This is the raw data of the crash.
Thread : Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x297c3c1f __exceptionPreprocess + 126
1 libobjc.A.dylib 0x36f97c8b objc_exception_throw + 38
2 CoreFoundation 0x297c9039 __methodDescriptionForSelector
3 CoreFoundation 0x297c6f57 ___forwarding___ + 714
4 CoreFoundation 0x296f8df8 _CF_forwarding_prep_0 + 24
5 UIKit 0x2cc8b1b5 -[UILabel _setFont:] + 100
6 MyApp 0x00137c29 -[MyViewController initUI] (MyViewController.m:90)
7 MyApp 0x0013765b -[MyViewController viewDidLoad] (MyViewController.m:51)
8 UIKit 0x2cc82f8f -[UIViewController loadViewIfRequired] + 602
9 UIKit 0x2cd2cd95 -[UINavigationController _layoutViewController:] + 32
10 UIKit 0x2cd2ccbd -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 228
11 UIKit 0x2cd2c253 -[UINavigationController _startTransition:fromViewController:toViewController:] + 74
12 UIKit 0x2cd2bf83 -[UINavigationController _startDeferredTransitionIfNeeded:] + 578
13 UIKit 0x2cd2bced -[UINavigationController __viewWillLayoutSubviews] + 44
14 UIKit 0x2cd2bc81 -[UILayoutContainerView layoutSubviews] + 184
15 UIKit 0x2cc804d7 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 514
16 QuartzCore 0x2c6a8a0d -[CALayer layoutSublayers] + 136
17 QuartzCore 0x2c6a43e5 CA::Layer::layout_if_needed(CA::Transaction*) + 360
18 QuartzCore 0x2c6a426d CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 16
19 QuartzCore 0x2c6a3c51 CA::Context::commit_transaction(CA::Transaction*) + 224
20 QuartzCore 0x2c6a3a55 CA::Transaction::commit() + 324
21 UIKit 0x2cc78965 _afterCACommitHandler + 132
22 CoreFoundation 0x2978a3b5 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
23 CoreFoundation 0x29787a73 __CFRunLoopDoObservers + 278
24 CoreFoundation 0x29787e7b __CFRunLoopRun + 914
25 CoreFoundation 0x296d6211 CFRunLoopRunSpecific + 476
26 CoreFoundation 0x296d6023 CFRunLoopRunInMode + 106
27 GraphicsServices 0x30a8f0a9 GSEventRunModal + 136
28 UIKit 0x2cce21d1 UIApplicationMain + 1440
29 MyApp 0x000a07e7 main (main.m:16)
30 libdyld.dylib 0x37517aaf start + 2
It's very likely that you are trying to get the length of what you think is an NSString but is actually NSNull.
I got this issue with my code & resolved it by using system fonts. The case was it couldn't load the font which I had specified into the code. Try & let me know if it help.
Happy Coding, cheers,
Ratneshwar

NSRange blockStartRange

Need your insight here...
This keeps crashing. Im calling a table on certain site, some say its the site that is causing but I can also make an exception. Can I get your two cents here?
NSRange blockStartRange = [pageContent rangeOfString:#"\t<table border=\"0\" cellpadding=\"4\" cellspacing=\"0\" id=\"table"];
NSRange blockEndRange = [pageContent rangeOfString:#"\t</table>" options:NSBackwardsSearch range:NSMakeRange(blockStartRange.location, [pageContent length] - blockStartRange.location)];
[HTMLString appendString:[pageContent substringWithRange:NSMakeRange(blockStartRange.location, blockEndRange.location + blockEndRange.length - blockStartRange.location)]];
// [HTMLString replaceOccurrencesOfString:#"width: 700px;" withString:#"" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [HTMLString length])];
}
[webView loadHTMLString:HTMLString baseURL:[NSURL URLWithString:#"http://bowlatrabs.com/"]];
}
Error Log
2014-08-01 15:52:22.092 Bowl at Rabs[61401:90b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSCFString rangeOfString:options:range:locale:]: Range {2147483647, 2147542871} out of bounds; string length 59222'
*** First throw call stack:
(
0 CoreFoundation 0x0270b1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x020178e5 objc_exception_throw + 44
2 CoreFoundation 0x0270afbb +[NSException raise:format:] + 139
3 Foundation 0x000c38cd -[NSString rangeOfString:options:range:locale:] + 185
4 Foundation 0x000cf156 -[NSString rangeOfString:options:range:] + 69
5 Bowl at Rabs 0x0002d9e8 -[LeagueController viewDidLoad] + 920
6 UIKit 0x005dc33d -[UIViewController loadViewIfRequired] + 696
7 UIKit 0x005dc5d9 -[UIViewController view] + 35
8 UIKit 0x005f6942 -[UINavigationController _startCustomTransition:] + 778
9 UIKit 0x006038f7 -[UINavigationController _startDeferredTransitionIfNeeded:] + 688
10 UIKit 0x006044e9 -[UINavigationController __viewWillLayoutSubviews] + 57
11 UIKit 0x007450d1 -[UILayoutContainerView layoutSubviews] + 213
12 UIKit 0x0052c964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
13 libobjc.A.dylib 0x0202982b -[NSObject performSelector:withObject:] + 70
14 QuartzCore 0x04d9b45a -[CALayer layoutSublayers] + 148
15 QuartzCore 0x04d8f244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
16 QuartzCore 0x04d8f0b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
17 QuartzCore 0x04cf57fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
18 QuartzCore 0x04cf6b85 _ZN2CA11Transaction6commitEv + 393
19 QuartzCore 0x04cf7258 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
20 CoreFoundation 0x026d336e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
21 CoreFoundation 0x026d32bf __CFRunLoopDoObservers + 399
22 CoreFoundation 0x026b1254 __CFRunLoopRun + 1076
23 CoreFoundation 0x026b09d3 CFRunLoopRunSpecific + 467
24 CoreFoundation 0x026b07eb CFRunLoopRunInMode + 123
25 GraphicsServices 0x035765ee GSEventRunModal + 192
26 GraphicsServices 0x0357642b GSEventRun + 104
27 UIKit 0x004bdf9b UIApplicationMain + 1225
28 Bowl at Rabs 0x0000239c main + 76
29 libdyld.dylib 0x0325d725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
You need to handle the case where the strings do not exist. Apple's documentation for the rangeOfString: method says: "Returns {NSNotFound, 0} if aString is not found or is empty (#"")."
So you need to check to see if the returned ranges have range.location == NSNotFound and handle that in whatever way is best.
Other way to check is using NSRangeFromString
NSRangeFromString: Returns a range from a textual representation.
If the string passed into NSRangeFromString does not represent a valid range, it will return a range with its location and length set to 0.
NSString *string = #"invalid";
NSRange range = NSRangeFromString(string);
// {.location=0, .length=0}
You might check nshipster/range

Why unknown selector when calling JSONRPC on XBMC?

can someone give me a hint why i always geht an
"DSJSONRPC doesNotRecognizeSelector" when calling jsonrpc interface from XBMC?
Result in console:
*** JSON-RPC REQUEST:
{
id = 654509193;
jsonrpc = "2.0";
method = "Player.GetActivePlayers";
params = {
};
}
Code:
DSJSONRPC *jsonRPC = [[DSJSONRPC alloc] initWithServiceEndpoint:[NSURL URLWithString:#"http://192.168.1.101:8080/jsonrpc"]];
[jsonRPC callMethod:#"Player.GetActivePlayers" withParameters:#{ }
onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError* internalError)
Using DSJSONRPC from Demiurgic JSON RPC
Can't find the error - on XBMC a movie is playing at this time...
Thanks in advance,
cheese
here the error stack:
2013-12-22 22:02:52.846 XBMCapp[3529:70b] *** JSON-RPC REQUEST:
{
id = "-1698136466";
jsonrpc = "2.0";
method = "Player.GetActivePlayers";
params = {
};
}
2013-12-22 22:02:52.847 XBMCapp[3529:70b] Error:<DSJSONRPC: 0x95c11b0>
2013-12-22 22:02:52.847 XBMCapp[3529:70b] -[DSJSONRPC localizedDescription]: unrecognized selector sent to instance 0x95c11b0
2013-12-22 22:02:52.873 XBMCapp[3529:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DSJSONRPC localizedDescription]: unrecognized selector sent to instance 0x95c11b0'
*** First throw call stack:
(
0 CoreFoundation 0x01ef25e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x018058b6 objc_exception_throw + 44
2 CoreFoundation 0x01f8f903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01ee290b ___forwarding___ + 1019
4 CoreFoundation 0x01ee24ee _CF_forwarding_prep_0 + 14
5 XBMCapp 0x000109ab -[DSJSONRPC callMethod:withParameters:onCompletion:] + 477
6 XBMCapp 0x000054df -[RootViewController nowplayingAction:] + 298
7 libobjc.A.dylib 0x01817874 -[NSObject performSelector:withObject:withObject:] + 77
8 UIKit 0x004780c2 -[UIApplication sendAction:to:from:forEvent:] + 108
9 UIKit 0x0074cc9b -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 139
10 libobjc.A.dylib 0x01817874 -[NSObject performSelector:withObject:withObject:] + 77
11 UIKit 0x004780c2 -[UIApplication sendAction:to:from:forEvent:] + 108
12 UIKit 0x0047804e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
13 UIKit 0x005700c1 -[UIControl sendAction:to:forEvent:] + 66
14 UIKit 0x00570484 -[UIControl _sendActionsForEvents:withEvent:] + 577
15 UIKit 0x0056f733 -[UIControl touchesEnded:withEvent:] + 641
16 UIKit 0x004b551d -[UIWindow _sendTouchesForEvent:] + 852
17 UIKit 0x004b6184 -[UIWindow sendEvent:] + 1232
18 UIKit 0x00489e86 -[UIApplication sendEvent:] + 242
19 UIKit 0x0047418f _UIApplicationHandleEventQueue + 11421
20 CoreFoundation 0x01e7b83f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
21 CoreFoundation 0x01e7b1cb __CFRunLoopDoSources0 + 235
22 CoreFoundation 0x01e9829e __CFRunLoopRun + 910
23 CoreFoundation 0x01e97ac3 CFRunLoopRunSpecific + 467
24 CoreFoundation 0x01e978db CFRunLoopRunInMode + 123
25 GraphicsServices 0x02d889e2 GSEventRunModal + 192
26 GraphicsServices 0x02d88809 GSEventRun + 104
27 UIKit 0x00476d3b UIApplicationMain + 1225
28 XBMCapp 0x0000234b main + 93
29 libdyld.dylib 0x02a2a70d start + 1
30 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
ok, found the problem - perhaps I have an old version of the JSON class...
There was an uninitialised error variable...
changing it to nil then everything works like a charm.
thanks anyway :)

Resources