Note that there are some explanatory texts on larger screens.

plurals
  1. POUnrecognized Selector on BOOL Property
    primarykey
    data
    text
    <p>I've been racking my brain over this seemingly simple issue. I have a XYZObject class where I declare:</p> <pre><code>@property BOOL checked; </code></pre> <p>In my View Controller, I import the object and whenever I use 'checked', the app compiles fine but breaks at runtime wherever 'checked' is used, for example:</p> <pre><code>XYZObject *tableitem = [myDictionary[currentCategory] objectAtIndex:indexPath.row]; if (tableitem.checked) { cell.accessoryType = UITableViewCellAccessoryCheckmark; } </code></pre> <p>This was working fine until I deleted and re-added the XYZObject class, so I've been debugging under the assumption that something in the file path is what's screwing things up. But I can click on 'checked' in my VC and under Quick Help it shows the proper reference to XYZObject. This is the exact error:</p> <pre><code>[__NSCFString checked]: unrecognized selector sent to instance </code></pre> <p><strong>EDIT/UPDATE:</strong></p> <p>With some help I've realized the issue is that when I changed my datasource from manual declaration in the ViewController, to importing a Plist, I completely scrapped my XYZObject and didn't account for it. Here is the original way I declared my dictionary:</p> <pre><code>XYZCategory *category1 = [[XYZCategory alloc]init]; category1.categoryArray = @"First Category"; [categoryArray addObject:category1]; XYZObject *object1 = [[XYZObject alloc]init]; object1.objectName = @"My String"; [objectArray addObject:object1]; myDictionary[category1.categoryArray] = objectArray; </code></pre> <p>When I switched to the Plist, the code changed to:</p> <pre><code>NSString *path = [[NSBundle mainBundle] pathForResource:@"myDictionaryPlist" ofType:@"plist"]; NSMutableDictionary *plistDictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:path]; objectArray = plistDictionary[@"First Category"]; myDictionary[category1.categoryArray] = objectArray; </code></pre> <p>And then for reference, XYZObject makes the following declarations:</p> <pre><code>@property NSString *objectName; @property BOOL checked; </code></pre> <p>So the dictionary problem would be that I'm just pulling the direct strings for the objectArray, instead of a set of XYZObjects. I'm going to keep testing but I'm pretty sure I just have to re-define objectArray to be a set of objects based on what's pulled from the Plist.</p> <p>But I also think that since I'm using the Plist now to create a dictionary (that is popped into a table where the Keys are sections and Values are rows), I can simplify things by removing the XYZCategory and XYZObject all together. Not sure if that's possible but I'm going to work towards it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload