現在、Xcode5でテーブルビューリスト形式のライン管理アプリを作ろうとしています。queue.h のプロパティである mutablearray を、可変配列プロパティを持つ queueviewcontroller に与えようとしています。これの主な理由は、オブジェクトがキューの配列である別の nsmutablearray を後で作成するためです。つまり、メンバーのリストのリストになります。何らかの理由で (Google と SO を検索しました)、アプリは問題なくコンパイルされますが、シミュレーターを実行すると黒い画面しか表示されません。
私はプログラミングに比較的慣れていないので、助けていただければ幸いです。必要な追加情報がある場合は、お知らせください。
Queue は、arrayQueue と呼ばれる NSMutableArray のプロパティを持つ NSObject サブクラスです。
ストーリーボードは、tableviewcontroller( QueueViewController
) が接続された navcontroller のみです。
これは QueueViewController.m のコードです。.h ファイルには *queue; という名前の nsmutable 配列のプロパティしかありません。
@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;
}
アプリ全体の 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