我試圖讓這個工作,讓我解釋什麼即時嘗試做,然後我會顯示一些代碼。好吧,我有一個導航控制器的UITableView,當你選擇一行時,它會加載一個詳細視圖。NSString不會通過類之間
我已經做了一個字符串,將攜帶哪些行被選中,所以我可以知道什麼顯示在視圖上。字符串不會在這兩個類之間傳遞,只是出現null,即使當我嘗試NSLog字符串在同一類中的另一個方法它仍然會出現null,唯一的地方,它會實際顯示它裏面是什麼它創建的方法。
讓我告訴你一些代碼,我將嘗試不同的方法來做到這一點,並且都推出了零 第一class.h
@interface features : UITableViewController{
NSMutableArray *featuresTableViewSet;
NSString *selectedFeature;
}
@property (nonatomic, retain) NSMutableArray *featuresTableViewSet;
@property (nonatomic, retain) NSString *selectedFeature;
-(NSString *)get;
@end
第一class.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
selectedFeature = [[NSString alloc]init];
selectedFeature = [featuresTableViewSet objectAtIndex:indexPath.row];
// Navigation logic may go here. Create and push another view controller.
features_detail *detailViewController = [[features_detail alloc] initWithNibName:@"features_detail" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
}
-(NSString *)get{
NSLog(@"%@", selectedFeature);
return selectedFeature;
}
現在這裏是類im試圖使用字符串
i #import "features.h"
第一類到第二個
這裏是第二類
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
features *selected = [[features alloc]init];
self.title = selected.selectedFeature;
NSLog(@"%@", [selected get]);
NSLog(@"%@", selected.selectedFeature);
}
一兩件事情Im做的應該工作權.M?
謝謝:)
你是個天才。完美的作品現在謝謝! – Jacob