Note that there are some explanatory texts on larger screens.

plurals
  1. POApplication (tableview) is crashing while scrolling
    primarykey
    data
    text
    <p>I'm making an app which tries to read the information from the <strong>.plist</strong> file (put there parsed <strong>JSON</strong>). </p> <p>The reading from file flows nice: got the array of dictionaries, but while trying to display it on tableview, the problems start. The initial view is loaded properly, but when I start scrolling, the app crashes. </p> <pre><code>#define DOCUMENTS [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] - (void)viewDidLoad { [super viewDidLoad]; NSString *filePathDocArray = [DOCUMENTS stringByAppendingPathComponent:@"filters.plist"]; NSString *filePathBundleArray = [[NSBundle mainBundle] pathForResource:@"filters" ofType:@"plist"]; if (![[NSFileManager defaultManager] fileExistsAtPath:filePathDocArray]) { [[NSFileManager defaultManager] copyItemAtPath:filePathBundleArray toPath:filePathDocArray error:nil]; NSLog(@"File saved"); } else { NSLog(@"File already exists"); filters = [NSArray arrayWithContentsOfFile:filePathDocArray]; } } </code></pre> <p><strong>Here I get all the info I need into filters array (checked by looping). Then:</strong></p> <pre><code>- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [filters count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *myIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:myIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:myIdentifier]; } NSInteger crow = indexPath.row; NSDictionary *story = [filters objectAtIndex: crow]; cell.textLabel.text = [story objectForKey:@"Name"]; cell.detailTextLabel.text = [story objectForKey:@"Description"]; return cell; } @end </code></pre> <p><strong>When the app starts everething is OK: I see the normel table view, but when I start scrolling it crashes</strong></p> <p>After series of breakpoint debugs I evaluated, that after the applications starts on Simulator, the link on array <strong>filters</strong> screws, so when I try to populate the next cell, the <strong>story</strong> dictionary can't be properly created. </p> <p>What sort of problem it can be?</p> <p>Here the console report:</p> <blockquote> <p><code>2012-09-22 13:37:43.545 JSONExample[4559:207] -[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x6a083c0</code></p> <p><code>2012-09-22 13:37:43.547 JSONExample[4559:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException',</code> <code>reason: '-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x6a083c0'</code></p> </blockquote>
    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.
 

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