Reputation: 175
I'm currently trying to make a line management app in the form of a table view list in Xcode5. I am trying give the mutablearray that is a property of queue.h to queueviewcontroller which also has a mutable array property. The main reason for this is that I will later create another nsmutablearray whose objects are the arrays of queue i.e. it will be a list of lists of members. for some reason (I've searched Google and SO) the apps compiles fine i.e. no issues but when I run the simulator, it only produces a black screen.
I'm relatively new at programming so any help is appreciated. If there is additional information you guys need please let me know.
Queue is an NSObject subclass with a property of NSMutableArray called arrayQueue
the storyboard is only a navcontroller with its attached tableviewcontroller(QueueViewController
).
this is the code from QueueViewController.m the .h file only has a property of nsmutable array named *queue;
@implementation QueueViewController
{
Queue *list;
}
- (void)viewDidLoad
{
[super viewDidLoad];
list = [[Queue alloc]init];
QueueMember *member = [[QueueMember alloc]init];
member.name = @"adam";
member.rank = 1;
member.eta = 5;
[list.arrayQueue addObject:member];
member = [[QueueMember alloc]init];
member.name = @"bob";
member.rank = 2;
member.eta = 10;
[list.arrayQueue addObject:member];
member = [[QueueMember alloc]init];
member.name = @"cason";
member.rank = 3;
member.eta = 15;
[list.arrayQueue addObject:member];
QueueViewController *queueViewController = [[QueueViewController alloc]init];
queueViewController.queue = list.arrayQueue;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"QueueCell"];
QueueMember *member = (self.queue)[indexPath.row];
cell.textLabel.text = member.name;
cell.detailTextLabel.text = [NSString stringWithFormat:@"%d min", member.eta];
return cell;
}
the entire app delegate.m
#import "AppDelegate.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
Upvotes: 0
Views: 426
Reputation: 11197
You didn't set the rootViewController
of window
.
EDIT:
You can create the array in viewDidLoad
. In viewDidLoad
write:
list = [[Queue alloc]init];
QueueMember *member = [[QueueMember alloc]init];
member.name = @"adam";
member.rank = 1;
member.eta = 5;
[list.arrayQueue addObject:member];
member = [[QueueMember alloc]init];
member.name = @"bob";
member.rank = 2;
member.eta = 10;
[list.arrayQueue addObject:member];
member = [[QueueMember alloc]init];
member.name = @"cason";
member.rank = 3;
member.eta = 15;
[list.arrayQueue addObject:member];
Upvotes: 2