I'm pretty new to this, but when I try to simulate on the iOS simulator it stops and then this error pops up...I added a View Controller for my a table view in my storyboard. I will include the file so you guys have enough info to help me out.
Im just trying to get my table view to display some elements of an array. A navigation controller is the root view controller and it goes right into the table view controller where I want to display the array courses.
Here is my app deligate
//AppDeligate.m
#import "AppDelegate.h"
#import "CoursesViewController.h"
#import "Courses.h"
@implementation AppDelegate{
NSMutableArray *courses;}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions
(NSDictionary *)launchOptions
{
courses = [NSMutableArray arrayWithCapacity:20];
Courses *course = [[Courses alloc] init];
course.code = @"SFWR 3X03";
course.units = 3;
[courses addObject:course];
UINavigationController *navigationController =
(UINavigationController *)self.window.rootViewController;
CoursesViewController *CoursesViewController =
[[navigationController viewControllers] objectAtIndex:1];
CoursesViewController.courses = courses;
return YES;
}
Here is my CoursesViewController.m
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
// Return the number of rows in the section.
return [self.courses count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath
*)indexPath
{
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"PlayerCell"];
Courses *course = [self.courses objectAtIndex:indexPath.row];
cell.textLabel.text = course.code;
return cell;
}
Here is my coursesviewcontroller.h
#import <UIKit/UIKit.h>
@interface CoursesViewController : UITableViewController
@property (nonatomic, strong) NSMutableArray *courses;
@end
Here is my courses.m and courses.h
#import "Courses.h"
@implementation Courses
@synthesize code;
@synthesize units;
.
#import <Foundation/Foundation.h>
@interface Courses : NSObject
@property (nonatomic, copy) NSString *code;
@property (nonatomic, assign) int units;
@end
@end
When I try to run in the simulator, it flips to the main.m file and displays the SIGARBT error on thread 1.
If I havent included enough info let me know and ill post more.
CONSOLE OUTPUT:
2012-10-04 14:44:14.726 MacMarks[475:c07] *** Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the
"fBI-R0-7j9-view-iYf-OA-4cJ" nib but didn't get a UITableView.'
*** First throw call stack:
(0x1c8e012 0x10cbe7e 0x1c8ddeb 0x242417 0xf4648 0xf4882 0xf4b2a 0x10bef5 0x10bfdb 0x10c286
0x10c381 0x10ceab 0x10cfc9 0x10d055 0x2123ab 0x6392d 0x10df6b0 0x228afc0 0x227f33c
0x228aeaf 0x1028cd 0x4b1a6 0x49cbf 0x49bd9 0x48e34 0x48c6e 0x49a29 0x4c922 0xf6fec 0x43bc4
0x43dbf 0x43f55 0x4cf67 0x10fcc 0x11fab 0x23315 0x2424b 0x15cf8 0x1be9df9 0x1be9ad0
0x1c03bf5 0x1c03962 0x1c34bb6 0x1c33f44 0x1c33e1b 0x117da 0x1365c 0x22fd 0x2225)
libc++abi.dylib: terminate called throwing an exception
(lldb)