(void)viewDidLoad
{
[super viewDidLoad];
UIImage *image1 = [UIImage imageNamed: @"logo.png"];
UIImageView *imageView1 = [[UIImageView alloc] initWithImage: image1];
self.navigationItem.titleView = imageView1;
self.navigationItem.leftBarButtonItem = nil;
self.navigationItem.hidesBackButton = YES;
@try
{
NSUserDefaults *def5=[NSUserDefaults standardUserDefaults];
NSLog(@"%@",[def5 objectForKey:@"id"]);
if ([[def5 objectForKey:@"id"]isEqualToString:NULL])
{
storeinformation=[[NSMutableArray alloc]init];
dict=[[NSMutableDictionary alloc]init];
[dict setValue:@"Mine Annonser" forKey:@"name"];
[dict setValue:@"2" forKey:@"id"];
[storeinformation addObject:dict];
dict=[[NSMutableDictionary alloc]init];
[dict setValue:@"Sett inn annonse" forKey:@"name"];
[dict setValue:@"3" forKey:@"id"];
[storeinformation addObject:dict];
}
else
{
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
Logindisplay *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"log"];
[self.navigationController pushViewController:vc animated:YES];
}
}
@catch (NSException *exception)
{
NSLog(@"error in loading in vc%@", exception.reason);
}
image1=Nil;
imageView1=nil;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [storeinformation count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
@try
{
NSUserDefaults *def6=[NSUserDefaults standardUserDefaults];
if ([[def6 objectForKey:@"id"]isEqualToString:NULL])
{
static NSString *CellIdentifier=@"afterlogin";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell==nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// arr=[storeinformation objectAtIndex:indexPath.row];
//NSLog(@"%@",arr);
NSMutableDictionary *dict1=[storeinformation objectAtIndex:indexPath.row];
UILabel *lbl=(UILabel*)[cell viewWithTag:1];
lbl.text= [dict1 objectForKey:@"name"];
UIImageView *img2=(UIImageView*)[cell viewWithTag:100];
img2.image=[UIImage imageNamed:@"arrows.png"];
/ / NSLog(@"%@",[storeinformation objectAtIndex:0]);
return cell;
//dict1=Nil;
// lbl=Nil;
}
}
@catch (NSException *e)
{
NSLog(@"Error in row at index path%@",e.reason);
}
}
答案 0 :(得分:0)
你可以在备用的想法k中使用它,用于存储本地平均值的登录crentIal(使用NSUserDefault),在AppDelegate.m中调用此NSUserdefault,此方法用于直接调用特定的视图控制器,否则你通过seque在登录视图控制器中。