0

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
snapfish
  • 175
  • 1
  • 14
  • http://stackoverflow.com/questions/6600257/iphone-getting-black-screen-on-app-launch?rq=1 ? –  Feb 16 '14 at 05:01
  • i appreciate the fast response. im a bit confused since I dont think im using a MainWindow.xib view outlet as this is xcode5. also, im not sure where the Main Interface in the Application Target Settings window is? the other answers revolve splashscreen which is not relevant to my situation since it's not an issue of delay in the launch but rather it just doesnt launch – snapfish Feb 16 '14 at 05:10
  • What do you done with this QueueViewController ? SHow us the code of this viewcontroller – Kumar KL Feb 16 '14 at 05:12
  • http://stackoverflow.com/questions/14487024/ios-application-launch-black-screen-uinavigationcontroller-nib-rootviewcontro – Kumar KL Feb 16 '14 at 05:18
  • thank you for the link, i posted the code above and I was wondering how should i set the root view controller in my case? I'm trying to add the following code but I'm not sure what to place as the parameter for initWithRootViewController? UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:rootView]; self.window.rootViewController = navController; – snapfish Feb 16 '14 at 05:42
  • i used rootView here which is not declared and does not work. thank you for the help. – snapfish Feb 16 '14 at 05:43

1 Answers1

2

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];
Rashad
  • 11,057
  • 4
  • 45
  • 73
  • i thought i was setting the rootViewController as the navigationController in this code. also the storyboard has the navigationcontroller as the initial view which has worked thus far for me on other apps. Do you mean i should add something like this on top of uinavigationcontroller *navigationcontroller?: – snapfish Feb 16 '14 at 05:21
  • UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier: UINavigationController]; self.window.rootViewController = viewController – snapfish Feb 16 '14 at 05:22
  • im unsure as to how to instantiate since storyboard isn't an actual class/type. – snapfish Feb 16 '14 at 05:48
  • i changed the end of the code to this which results in a crash due to "index zero is beyond bounds for empty array". could someone let me know if I'm in the right direction at least? – snapfish Feb 16 '14 at 06:00
  • self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. UINavigationController *viewController = [[UINavigationController alloc] initWithNibName:@"YourFirstViewController" bundle:nil]; self.window.rootViewController = viewController; UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController; QueueViewController *queueViewController = [navigationController viewControllers][0]; queueViewController.queue = list.arrayQueue; – snapfish Feb 16 '14 at 06:00
  • You are doing it wrong wait. I am going to share some code for navigation controller. – Rashad Feb 16 '14 at 06:02
  • But first please explain what you are going to do. – Rashad Feb 16 '14 at 06:03
  • i am trying give the array i set up in delegate to the queueviewcontroller so it can load it. i thought i should do this by going through the views starting from the rootview to the navcontroller to the queueviewcontroller since storyboard needs this to be done in code. Thank you for helping so much and being patient. – snapfish Feb 16 '14 at 06:07
  • See my edit. is there any reason for creating the queue in AppDelegate? – Rashad Feb 16 '14 at 06:21
  • not in particular, i merely saw it in a tutorial and thought it was better. The starting tutorial from apple (the most basic one) does it in viewdidload. based on ur edit, should i make delegate.m didfinishlaunchingwithoptions return yes and delete everything else? – snapfish Feb 16 '14 at 06:37
  • Yeah. That would be fine. – Rashad Feb 16 '14 at 06:39
  • i made the changes u suggested and im still stuck at the black screen. when i make the array in queueviewcontroller viewdidload, do i keep or delete the [super viewdidLoad]? also given this new setup, where do i set the property queue(NSMutableArray) of queueviewcontroller as list.arrayQueue (the array we made in viewdidload? the point is to have the two arrays be equal so that when i edit the class queue and its instances this will be reflected back into the model and shown in queueviewcontroller. – snapfish Feb 16 '14 at 06:54
  • Keep [super viewdidLoad]. You can set the array in viewDidLoad. – Rashad Feb 16 '14 at 07:01
  • i edit the code (see question again) and the black screen is still there. Any other suggestions? i also provided more information on the nature of the app as a whole (a list of lists of members) if that helps. Thanks again. – snapfish Feb 16 '14 at 07:17
  • Are you using storyboard? Can you post current appdelegate.m? – Rashad Feb 16 '14 at 07:40
  • yes i am using storyboard but it only has a navigation controller with an attached tableviewcontroller using the class queueviewcontroller. i just updated all the code for app delegate.m into the question. – snapfish Feb 16 '14 at 07:45
  • Is QueueViewController is the root viewcontroller of Navigation controller? I think you are missing this part. Check that the navigation controller has a root view controller. You can check this tutorial: http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1 – Rashad Feb 16 '14 at 07:50
  • yes it is. there is a relationship "root view controller" to queue in the navigationcontroller. i actually went through the storyboards tutorials from raywenderlich before doing this app. i used the ios7 version andfound it very helpful. – snapfish Feb 16 '14 at 07:59
  • i remake everything from the beginning but set the array in viewDidLoad rather than appdelegate and it worked. Thanks for everything. – snapfish Feb 17 '14 at 01:16
  • Welcome. Keep coding and helping people. :) – Rashad Feb 17 '14 at 03:56