Code:
for (i = 0; i < [classIDs count]; i++)
{
NSLog(@"Adding a %i section", i);
[sections addObject:[[NSMutableArray alloc] init]];
if ([[[sections objectAtIndex:i] class] isKindOfClass: [[sections objectAtIndex:i] class]])
{
NSLog(@"It said it was right before...");
}
else
{
NSLog(@"The test sucks...");
}
}
I have "The test sucks..." returned every time.
This either means Apple's class and isKindOfClass: methods are poorly written or I'm misusing them.
I suspect I'm misusing them.
Can someone please explain them to me?
And a follow up... I actually don't want to check to see if an object is of its own class, I want to check to see
Code:
if ([[[sections objectAtIndex:section] class] isKindOfClass: [NSMutableArray class]])
... here's that code too, I guess, seeing as I can't figure it out either.
Code:
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
NSLog(@"%@", [classNames objectForKey:[[[sections objectAtIndex:section] objectAtIndex:0] objectForKey:@"ClassID"]]);
return [classNames objectForKey:[[[sections objectAtIndex:section] objectAtIndex:0] objectForKey:@"ClassID"]];
}
When it returns an error when crashing, it says the issue pertains to objectAtIndex being sent to an object that doesn't recognize it. The worse part is, it seems to vary from build to build what it's sending it to. Sometimes it says UniqueIndexPath or something like that was sent it. I can't remember the others and I didn't write them down unfortunately. Oh, and then most of the time it simply crashes without logging a single error...
it'll print the titles of the headers like the NSLog tells it to, but there's nothing after that and the app has crashed.
So... help?
1.) I can't figure out how to use class and isKindOfClass: properly...
2.) Periodically the object in an array seems to be of the wrong class and thus incapable of responding to a method I send it...
Edit:
Okay, sometimes it ends up returning
-[UIButtonContent objectAtIndex:]: unrecognized selector sent to instance 0x392a880'
Furthermore, I replaced the whole "isKindOfClass:" test with a "respondsToSelector" test... and the result is, it NSMutableArray when the object is initially created and added, but later fails.
This makes me wonder if maybe the system also has a variable called sections? IDK...
help!
The truly baffling part is that the NSLog immediately before still works.
I've modified it a little more... now it does this:
Code:
NSString *titleHeader = [NSString stringWithFormat:@"%@", [classNames objectForKey:[[[sections objectAtIndex:section] objectAtIndex:0] objectForKey:@"ClassID"]]];
NSLog(@"%@", titleHeader);
return titleHeader;
The NSLog STILL displays the correct title.
And afterwards I get this error:
I am getting so frustrated... why isn't it working?-[UIDeviceRGBColor objectAtIndex:]: unrecognized selector sent to instance 0x3b15690
Edit 2X:
Without changing a single line of code and building it again, I got this now:
-[UIButtonContent objectAtIndex:]: unrecognized selector sent to instance 0x3b1e120
Edit 3X:
And now CALayer has received it...
Edit 4X:
And now UIControlTargetAction has received it...