· 8 years ago · Aug 18, 2018, 10:54 AM
1Sigbart Error: 'NSInvalidArgumentException'
22011-10-24 08:56:29.746 DiningLog[2955:207] -[NSCFString setTableViewStyle:]: unrecognized selector sent to instance 0x595b150
32011-10-24 08:56:29.749 DiningLog[2955:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString setTableViewStyle:]: unrecognized selector sent to instance 0x595b150'
4*** Call stack at first throw:
5(
6 0 CoreFoundation 0x00fa25a9 __exceptionPreprocess + 185
7 1 libobjc.A.dylib 0x010f6313 objc_exception_throw + 44
8 2 CoreFoundation 0x00fa40bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
9 3 CoreFoundation 0x00f13966 ___forwarding___ + 966
10 4 CoreFoundation 0x00f13522 _CF_forwarding_prep_0 + 50
11 5 UIKit 0x00330bd5 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 695
12 6 UIKit 0x003264cc -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
13 7 UIKit 0x0033b8cc -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
14 8 UIKit 0x0033390c -[UITableView layoutSubviews] + 242
15 9 QuartzCore 0x01f42a5a -[CALayer layoutSublayers] + 181
16 10 QuartzCore 0x01f44ddc CALayerLayoutIfNeeded + 220
17 11 QuartzCore 0x01eea0b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
18 12 QuartzCore 0x01eeb294 _ZN2CA11Transaction6commitEv + 292
19 13 UIKit 0x002bd9c9 -[UIApplication _reportAppLaunchFinished] + 39
20 14 UIKit 0x002bde83 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 690
21 15 UIKit 0x002c8617 -[UIApplication handleEvent:withNewEvent:] + 1533
22 16 UIKit 0x002c0abf -[UIApplication sendEvent:] + 71
23 17 UIKit 0x002c5f2e _UIApplicationHandleEvent + 7576
24 18 GraphicsServices 0x018fa992 PurpleEventCallback + 1550
25 19 CoreFoundation 0x00f83944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
26 20 CoreFoundation 0x00ee3cf7 __CFRunLoopDoSource1 + 215
27 21 CoreFoundation 0x00ee0f83 __CFRunLoopRun + 979
28 22 CoreFoundation 0x00ee0840 CFRunLoopRunSpecific + 208
29 23 CoreFoundation 0x00ee0761 CFRunLoopRunInMode + 97
30 24 UIKit 0x002bd7d2 -[UIApplication _run] + 623
31 25 UIKit 0x002c9c93 UIApplicationMain + 1160
32 26 DiningLog 0x0000213c main + 102
33 27 DiningLog 0x000020cd start + 53
34)
35terminate called after throwing an instance of 'NSException'
36Current language: auto; currently objective-c
37(gdb)
38
39//
40// RootViewController.m
41// DiningLog
42//
43// Created by Eric Rea on 3/3/11.
44// Copyright 2011 Avid. All rights reserved.
45//
46
47#import "RootViewController.h"
48#import "ModalView.h"
49
50@interface RootViewController ()
51- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath;
52@end
53
54
55@implementation RootViewController
56
57@synthesize fetchedResultsController=fetchedResultsController_, managedObjectContext=managedObjectContext_;
58@synthesize plistArray, excersizeArray;
59
60
61#pragma mark -
62#pragma mark View lifecycle
63
64- (void)viewDidLoad {
65 [super viewDidLoad];
66
67 // Set up the edit and add buttons.
68 self.navigationItem.leftBarButtonItem = self.editButtonItem;
69
70 UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject)];
71 self.navigationItem.rightBarButtonItem = addButton;
72 [addButton release];
73
74 // get paths from root direcory
75 NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
76 // get documents path
77 NSString *documentsPath = [paths objectAtIndex:0];
78 // get the path to our Data/plist file
79 NSString *plistPath = [documentsPath stringByAppendingPathComponent:@"ExcersizeList.plist"];
80
81 // check to see if Data.plist exists in documents
82 if (![[NSFileManager defaultManager] fileExistsAtPath:plistPath])
83 {
84 // if not in documents, get property list from main bundle
85 plistPath = [[NSBundle mainBundle] pathForResource:@"Excersizes" ofType:@"plist"];
86 }
87
88 // read property list into memory as an NSData object
89 NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];
90 NSString *errorDesc = nil;
91 NSPropertyListFormat format;
92 // convert static property list into dictionary object
93 NSDictionary *temp = (NSDictionary *)[NSPropertyListSerialization propertyListFromData:plistXML mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&format errorDescription:&errorDesc];
94 if (!temp)
95 {
96 NSLog(@"Error reading plist: %@, format: %d", errorDesc, format);
97 }
98 // assign values
99 self.plistArray = [NSMutableArray arrayWithArray:[temp objectForKey:@"Excersizes"]];
100
101}
102
103
104- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
105 return [self.plistArray count];
106}
107
108- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
109 /* create your cell here */
110
111 excersizeArray = [self.plistArray objectAtIndex:[indexPath row]];
112
113 /* fill the cell with the info in my object */
114
115 return [excersizeArray objectAtIndex:(NSUInteger)0];
116 }
117
118
119// Implement viewWillAppear: to do additional setup before the view is presented.
120- (void)viewWillAppear:(BOOL)animated {
121 [super viewWillAppear:animated];
122}
123
124
125/*
126- (void)viewDidAppear:(BOOL)animated {
127 [super viewDidAppear:animated];
128}
129*/
130/*
131- (void)viewWillDisappear:(BOOL)animated {
132 [super viewWillDisappear:animated];
133}
134*/
135/*
136- (void)viewDidDisappear:(BOOL)animated {
137 [super viewDidDisappear:animated];
138}
139*/
140
141/*
142 // Override to allow orientations other than the default portrait orientation.
143- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
144 // Return YES for supported orientations.
145 return (interfaceOrientation == UIInterfaceOrientationPortrait);
146}
147 */
148
149
150- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
151
152 NSManagedObject *managedObject = [self.fetchedResultsController objectAtIndexPath:indexPath];
153 cell.textLabel.text = [[managedObject valueForKey:@"Excersizes"] description];
154}
155
156
157#pragma mark -
158#pragma mark Add a new object
159
160- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
161
162 // Prevent new objects being added when in editing mode.
163 [super setEditing:(BOOL)editing animated:(BOOL)animated];
164 self.navigationItem.rightBarButtonItem.enabled = !editing;
165}
166
167
168#pragma mark -
169#pragma mark Table view data source
170
171- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
172 return 20;
173}
174
175
176/*
177// Override to support conditional editing of the table view.
178- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
179 // Return NO if you do not want the specified item to be editable.
180 return YES;
181}
182*/
183
184
185// Override to support editing the table view.
186- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
187
188 if (editingStyle == UITableViewCellEditingStyleDelete) {
189 // Delete the managed object for the given index path
190 NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
191 [context deleteObject:[self.fetchedResultsController objectAtIndexPath:indexPath]];
192
193 // Save the context.
194 NSError *error = nil;
195 if (![context save:&error]) {
196 /*
197 Replace this implementation with code to handle the error appropriately.
198
199 abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. If it is not possible to recover from the error, display an alert panel that instructs the user to quit the application by pressing the Home button.
200 */
201 NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
202 abort();
203 }
204 }
205}
206
207
208- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
209 // The table view should not be re-orderable.
210 return NO;
211}
212
213
214#pragma mark -
215#pragma mark Table view delegate
216
217- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
218 // Navigation logic may go here -- for example, create and push another view controller.
219 /*
220 <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
221 NSManagedObject *selectedObject = [[self fetchedResultsController] objectAtIndexPath:indexPath];
222 // ...
223 // Pass the selected object to the new view controller.
224 [self.navigationController pushViewController:detailViewController animated:YES];
225 [detailViewController release];
226 */
227}
228
229
230#pragma mark -
231#pragma mark Fetched results controller
232
233- (NSFetchedResultsController *)fetchedResultsController {
234
235 if (fetchedResultsController_ != nil) {
236 return fetchedResultsController_;
237 }
238
239 /*
240 Set up the fetched results controller.
241 */
242 // Create the fetch request for the entity.
243 NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
244 // Edit the entity name as appropriate.
245 NSEntityDescription *entity = [NSEntityDescription entityForName:@"Event" inManagedObjectContext:self.managedObjectContext];
246 [fetchRequest setEntity:entity];
247
248 // Set the batch size to a suitable number.
249 [fetchRequest setFetchBatchSize:20];
250
251 // Edit the sort key as appropriate.
252 NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"Excersizes" ascending:NO];
253 NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
254
255 [fetchRequest setSortDescriptors:sortDescriptors];
256
257 // Edit the section name key path and cache name if appropriate.
258 // nil for section name key path means "no sections".
259 NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:@"Root"];
260 aFetchedResultsController.delegate = self;
261 self.fetchedResultsController = aFetchedResultsController;
262
263 [aFetchedResultsController release];
264 [fetchRequest release];
265 [sortDescriptor release];
266 [sortDescriptors release];
267
268 NSError *error = nil;
269 if (![fetchedResultsController_ performFetch:&error]) {
270 /*
271 Replace this implementation with code to handle the error appropriately.
272
273 abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. If it is not possible to recover from the error, display an alert panel that instructs the user to quit the application by pressing the Home button.
274 */
275 NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
276 abort();
277 }
278
279 return fetchedResultsController_;
280}
281
282
283#pragma mark -
284#pragma mark Fetched results controller delegate
285
286
287- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller {
288 [self.tableView beginUpdates];
289}
290
291
292- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo
293 atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type {
294
295 switch(type) {
296 case NSFetchedResultsChangeInsert:
297 [self.tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
298 break;
299
300 case NSFetchedResultsChangeDelete:
301 [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
302 break;
303 }
304}
305
306
307- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
308 atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
309 newIndexPath:(NSIndexPath *)newIndexPath {
310
311 UITableView *tableView = self.tableView;
312
313 switch(type) {
314
315 case NSFetchedResultsChangeInsert:
316 [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
317 break;
318
319 case NSFetchedResultsChangeDelete:
320 [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
321 break;
322
323 case NSFetchedResultsChangeUpdate:
324 [self configureCell:[tableView cellForRowAtIndexPath:indexPath] atIndexPath:indexPath];
325 break;
326
327 case NSFetchedResultsChangeMove:
328 [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
329 [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath]withRowAnimation:UITableViewRowAnimationFade];
330 break;
331 }
332}
333
334
335- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
336 [self.tableView endUpdates];
337}
338
339
340/*
341// Implementing the above methods to update the table view in response to individual changes may have performance implications if a large number of changes are made simultaneously. If this proves to be an issue, you can instead just implement controllerDidChangeContent: which notifies the delegate that all section and object changes have been processed.
342
343 - (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
344 // In the simplest, most efficient, case, reload the table view.
345 [self.tableView reloadData];
346}
347 */
348
349
350#pragma mark -
351#pragma mark Memory management
352
353- (void)didReceiveMemoryWarning {
354 // Releases the view if it doesn't have a superview.
355 [super didReceiveMemoryWarning];
356
357 // Relinquish ownership any cached data, images, etc that aren't in use.
358}
359
360
361- (void)viewDidUnload {
362 // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
363 // For example: self.myOutlet = nil;
364}
365
366
367- (void)dealloc {
368 [fetchedResultsController_ release];
369 [managedObjectContext_ release];
370 [super dealloc];
371}
372
373
374@end
375
376- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
377
378static NSString *CellIdentifier = @"Cell";
379
380UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
381if (cell == nil) {
382cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
383}
384
385// Set up the cell...
386cell.text = @"Value";
387
388return cell;
389}
390
391- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {