1

xcodeでiPhoneアプリケーションをテストしていますが、unkonwoエラーが発生しています

アプリケーションは、アプリケーションの起動の最後にルート ビュー コントローラーを持つことが期待されます。

ビューが読み込まれると、アプリケーションが壊れてこのエラーが発生する理由がわかりません

 My code where it breaks 

    - (void)viewDidLoad {
      [super viewDidLoad];
      if(!surveyList){
      surveyList=[[NSMutableArray alloc]init];
       }

      [self getSurveyList];

       }

      - (void)getSurveyList {

       NSString*user_id=user_id;
       NSLog(user_id);
      NSString *url=[NSString stringWithFormat:@"http://celeritas-solutions.com/emrapp/surveyDescription.php?user_id=%@",user_id];


    NSArray *tempArray =[[DataManager staticVersion] startParsing:url];

   for (int i = 0; i<[tempArray count]; i++) {

    id *item = [tempArray objectAtIndex:i];
    NSDictionary *dict = (NSDictionary *) item;
    ObjectData *theObject =[[ObjectData alloc] init];
    [theObject setSurvey_title:[dict objectForKey:@"survey_Title"]];
    [theObject setSurvey_Description:[dict objectForKey:@"survey_Description"]];    
    [theObject setDate_Created:[dict objectForKey:@"date_Created"]];




    [surveyList addObject:theObject];
    [theObject release];
    theObject=nil;




    int count =[surveyList count];
    NSLog(@"Total is %d",count);


    }
   }

ビューからこのメソッドを呼び出したときにこのエラーが発生し、メソッドをロードしました

4

2 に答える 2

1

AppDelegate で rootController を設定する必要があります

[self.window setRootViewController:tabBarController];

%d の代わりに %i を使用

int count =[surveyList count];
NSLog(@"Total is %i",count);
于 2012-07-25T09:33:14.800 に答える
0

AppDelegate.m ファイルで次のメソッドを設定する必要があります。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:  (NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]  autorelease];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
    self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease];
} else {
    self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil] autorelease];
}
UINavigationController *navigation =[[UINavigationController alloc]initWithRootViewController:self.viewController];
 navigation.navigationBar.hidden=YES;
self.window.rootViewController = navigation;
[self.window makeKeyAndVisible];
}    
于 2012-07-25T11:03:20.113 に答える