我正在xcode中测试iphone应用程序,但它给出了unkonwo错误
在应用程序启动结束时,应用程序应具有根视图控制器wait_vences:无法接收回复:10004003
我不知道为什么当视图被加载时,它会破坏应用程序并给出这个错误
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);
}
}
从视图调用此方法时出现此错误,加载方法
您必须在AppDelegate 中设置rootController
[self.window setRootViewController:tabBarController];
使用%i而不是%d
int count =[surveyList count];
NSLog(@"Total is %i",count);
您必须在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];
}