У меня проблема с загрузкой данных в виде таблицы. Когда представление загружается, я вижу таблицы, но в ячейке ничего не заполнено.
PMs.h
@interface Pms : TTTableViewController {
NSArray *rows;
TTTableSubtitleItem *item;
}
@property (retain,nonatomic) NSArray *rows;
PMs.m
- (void)dealloc {
[rows release];
[super dealloc];
}
- (id)init {
//[self.navigationController setNavigationBarHidden:NO];
if (self = [super init]) {
self.variableHeightRows = YES;
self.dataSource = nil;
}
return self;
}
-(void)getLatest{
NSURL *url = [NSURL URLWithString:@"http://URL.com/pms.php"];
NSString *jsonreturn = [[NSString alloc] initWithContentsOfURL:url];
NSData *jsonData = [jsonreturn dataUsingEncoding:NSUTF32BigEndianStringEncoding];
NSError *error = nil;
// In "real" code you should surround this with try and catch
NSDictionary * dict = [[[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error] retain];
NSMutableArray *zodiaq = (NSMutableArray *)[[dict objectForKey:@"users"] retain];
TTListDataSource* tableItems = [[[TTListDataSource alloc] init] autorelease];
for(NSDictionary *dict in zodiaq){
item = [TTTableSubtitleItem itemWithText:[dict objectForKey:@"from_user"] subtitle:[dict objectForKey:@"subject"]
imageURL:nil
defaultImage:nil
URL:@"tt://tableItemTest"
accessoryURL:nil];
[tableItems.items addObject:item];
}
self.dataSource = [TTListDataSource
dataSourceWithItems:tableItems.items];
[jsonreturn release];
}
- (void)loadView {
[super loadView];
[self setTableViewStyle:UITableViewStylePlain];
self.tableView.frame = CGRectMake(0, 44, 320, 396);
[self getLatest];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
@end
Когда я делаю
NSLog(@"Data: %@",[dict objectForKey:@"subject"]);
if показывает все извлекаемые строки темы, но не заполняет таблицы.