logo
down
shadow

Getting objectForKeyedSubscript unrecognized selector when parsing data in table view


Getting objectForKeyedSubscript unrecognized selector when parsing data in table view

By : user2955410
Date : November 22 2020, 10:40 AM
To fix this issue I am parsing a json file containing data to a table view with different custom cells. In the json file I have different types of channels, looking like this: , This line is incorrect,
code :
if (post[@"channel"][@"Channel1"]) {
if ([post[@"channel"] isEqualToString:@"Channel1"]) {


Share : facebook icon twitter icon
iOS GoogleMaps SDK error: "[__NSCFDictionary objectForKeyedSubscript:]: Unrecognized selector sent"

iOS GoogleMaps SDK error: "[__NSCFDictionary objectForKeyedSubscript:]: Unrecognized selector sent"


By : EM3
Date : March 29 2020, 07:55 AM
This might help you You may want to look into this question: objectForKeyedSubscript: crash on iOS 5.1
By the way, what's the version of Xcode you are using? What's the iOS SDK version you are using?
-[NSNull objectForKeyedSubscript:]: unrecognized selector sent to instance

-[NSNull objectForKeyedSubscript:]: unrecognized selector sent to instance


By : Hùng Nguyễn
Date : March 29 2020, 07:55 AM
wish of those help The way to fix it is to not attempt objectForKeyedSubscript on an NSNull object. (I'm betting you're handling some JSON data and aren't prepared for a NULL value.)
(And apparently objectForKeyedSubscript is what the new array[x] notation translates into.)
[__NSArrayM objectForKeyedSubscript:]: unrecognized selector sent to instance - source code and screenshot attached

[__NSArrayM objectForKeyedSubscript:]: unrecognized selector sent to instance - source code and screenshot attached


By : user7340522
Date : March 29 2020, 07:55 AM
it fixes the issue Your code thinks the JSON deserializes to an object (dictionary), but in fact it deserializes to an array containing one object. Try this:
code :
 NSMutableArray *topLevelArray = [NSJSONSerialization JSONObjectWithData:data
     options:NSJSONReadingMutableContainers error:nil];
 NSDictionary *dict = topLevelArray[0];
id jso = [NSJSONSerialization JSONObjectWithData:data
    options:NSJSONReadingMutableContainers error:nil];
if (jso == nil) {
    // Error.  You should probably have passed an NSError ** as the error
    // argument so you could log it.
} else if ([jso isKindOfClass:[NSArray class]]) {
    NSArray *array = jso;
    // process array elements
} else if ([jso isKindOfClass:[NSDictionary class]]) {
    NSDictionary *dict = jso;
    // process dictionary elements
} else {
    // Shouldn't happen unless you use the NSJSONReadingAllowFragments flag.
}
-[__NSArrayI objectForKeyedSubscript:]: unrecognized selector sent to instance IN xcode6 objective-c ios

-[__NSArrayI objectForKeyedSubscript:]: unrecognized selector sent to instance IN xcode6 objective-c ios


By : 03stories
Date : March 29 2020, 07:55 AM
This might help you I can only tell you what's happening in your code, not where it's happening, as you've not posted the offending code.
The objectForKeyedSubscript method is called for NSDictionary subscripting, for example:
code :
NSDictionary *dict = @{ @"key" : @"value" };
NSString *value = dict[@"key"];    // HERE
for(int i=0; i < 3; i++){
    [_myMutableArray addObjects: [NSNumber numberWithInt: i]
}
NSNumber *num = _myMutableArray[@"3"];    // !!!!
-[__NSCFNumber objectForKeyedSubscript:]: unrecognized selector sent to instance

-[__NSCFNumber objectForKeyedSubscript:]: unrecognized selector sent to instance


By : RonRon
Date : March 29 2020, 07:55 AM
it should still fix some issue So I have been stuck on this for a while now and I have looked through many many posts on Stackoverflow but I still can't seem to figure out how to solve the problem. It seems to me that "dict" is supposed to be converted to a string so I have tried that in many ways, such as using NSString *myString = [NSNumber stringValue];, [NSString stringWithFormat:@"%d", dict[@"id"]]; and a few others. Here is the code: , // try like this it will work
code :
for (NSDictionary *dict in self.params) {
if([dict isKindOfClass:[NSDictionary class]]) {
  NSString *value = [NSString stringWithFormat:@"%@",dict[@"id"]];

  if (value) {
      [parameters appendFormat:@"&ids[]=%@", value];
  }
}
}
Related Posts Related Posts :
  • CordovaError: Promise rejected with non-error: Error code 65
  • How to append NSMutable strings into a UILabel
  • CustomCell label value does not change
  • Display ad in iAd Bannerview iAd Network
  • Warning: "Could not get traitsetID for iPhone11,6" (Assets.xcassets)
  • Changing root view controller after iOS app has loaded.
  • SocketRocket and iOS certificate pinning
  • Draggable UIButton Snap To a Circle Path
  • Running FireBase in the background
  • resizing UIPopoverController to fit UITableController
  • UICollectionView Exception Crash
  • targeting iOS5 - will it work on iOS6 also?
  • FBLoginView get email
  • Scale UIImages height to UIImageView height
  • Creating a custom progress indicator in ios
  • NSRunLoop API difference
  • Is it possible to inject custom settings into my iOS application "Notifications" settings dialog?
  • UIAlertview not accepting string as message
  • Axis change of stackView giving layout error
  • How to use AVAssetResourceLoader?
  • How to write block definition using properties?
  • iOS connect/reconnect to Bluetooth device when using external-accessory and MFi
  • Saving XMPP Multi User chat messages through XMPP MessageArchiving in iOS
  • Deciding iOS version: pros and cons
  • iOS: Resigned app cannot access keychain through security API
  • How can I set To and Subject fields in an E-Mail being sent by UIDocumentInteractionController?
  • Updating uilabel in view controller underneath another
  • Maximum time Intervel for NSTimer
  • Delete Core Data Entry from Table View Controller
  • How to unload UIViewcontroller from memory?
  • Compressing UIImage as Far as Possible?
  • Optimizing workflow to update internally owned cocoapods dependencies?
  • Formatting an NSDate with Abbreviated Month/Day Names
  • I'm creating a quiz game with 4 answers and I want to add score
  • Tap Gesture to Hide Navigation Bar, Tab Bar, and Status Bar
  • FBSessionStateClosedLoginFailed when I am logged in through Settings
  • CGRect positioning according to center point
  • iOS: Update table view datasource with animations without core data
  • iOS : Where to start for AliPay integration?
  • Routing App Coverage File missing but not needed?
  • Drawing on a zoomable view
  • Append NSStrings and NSNumber to NSMutableArrays and make NSMutable dictionary
  • Terminating app due to uncaught exception 'NSRangeException' when calling dequeueReusableCellWithReuseIdentifier:forInde
  • Collision without physics (Cocos2D + Box2D iOS)
  • Creating a percentage based iOS layout
  • Update tableView row from AppDelegate Swift 4
  • Assigning return value of a class method to a variable error
  • how to display circular progress in delphi ios apps?
  • I can't figure how to fix this Expected identifier or '('
  • How to Test APIs in Swift 4?
  • Link error /Build/Products/Debug-iphonesimulator file not found
  • working with a very large JSON object in iOS
  • Turn off part of the iPhone Screen
  • Phonegap 3.0 app with facebook login using xCode
  • How to add interstitial admob ads to my ios project
  • adding tapku calendar to ios app
  • Add an alertcontroller in a global swift file?
  • Take square image with Cordova (Phonegap) Camera API?
  • Amazon S3 policy allowing only upload not overwrite
  • How to change the UILabel content by tapping?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org