我有一个简单的应用程序是:从一个服务器上的负载传递数组从模型到表视图内的UITabBarController
- 返回数据
- 包含一个
UITabBarController
与2项ViewController
和TableViewController
。该视图是用户看到的第一个选项卡。
我有一个模型,我通过调用这个数据创造:
self.tide = [[TideModel alloc] initWithJSON:userLocationAsString];
我通过经度和纬度,并返回JSON。我有我的观点,然后访问这些数据并在屏幕上显示没有问题。我现在想要解决的是如何将这些数据传递给我的TableViewController
?
TableViewController.m:(返回null
- (void)viewDidLoad
{
[super viewDidLoad];
self.tide = [[TideModel alloc] init];
NSLog(@"%@", self.tide.tideSummary);
}
TableViewController.h
@property (strong, nonatomic) TideModel *tide;
事情很少
- 我正在初始化我的模型
initWithJSON
- 当用户查看tableview时,模型已经填充了数据,所以我不需要重新发送JSON(这会超过kill)。如下:
- 请问如果我用从一个单一的模式
initWithJSON数据需要赛格瑞
-(id)initWithJSON:(NSString *)location {
self = [super init];
if(self) {
NSString *locationQueryURL = [NSString stringWithFormat:@"http://x/location/%@", location];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:locationQueryURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
// Extra code cut out to save space
..................
..................
..................
self.maxheight = [NSString stringWithFormat:@"%@", [dctOfTideSummaryStats valueForKey: @"maxheight"]];
self.tideSummary = [responseObject valueForKeyPath:@"tide.tideSummary"];
return self;
}
什么是用最好的方式从我的TableViewController中使用的initWithJSON
创建和初始化相同的数据? 想法?
如果NSLog(@“%@”,self.tide.tideSummary)正在打印正确的数据,然后在viewDidLoad方法,那么你可以简单地把这些数据放在你的TableView中。我想你不应该有任何问题做到这一点! – Nayan
它返回'''(null)''' - 我会更新我的问题 – Coughlin
@NSS我看着一个segue,但我没有通过插座发送。可以肯定,赛格是不正确的?也许如果我从tableview - > detailview(没有标签栏) – Coughlin