Note that there are some explanatory texts on larger screens.

plurals
  1. POPutting my JSON into a tableView
    primarykey
    data
    text
    <p>what i'm currently trying to do is get my json information (twitter user timeline) and stick it into a table, everything about it json works, but when it comes to adding the information to the tableView it doesn't do anything about it, Here is my code :</p> <pre><code>#import "FirstViewController.h" #import &lt;Twitter/Twitter.h&gt; #import &lt;Accounts/Accounts.h&gt; @interface FirstViewController () - (void)fetchData; @end @implementation FirstViewController @synthesize timelineTwiter = _timelineTwiter; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { self.title = NSLocalizedString(@"First", @"First"); self.tabBarItem.image = [UIImage imageNamed:@"first"]; } return self; } -(void)fetchData { ACAccountStore *store = [[ACAccountStore alloc] init]; ACAccountType *twitterAccountType = [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; [store requestAccessToAccountsWithType:twitterAccountType withCompletionHandler:^(BOOL granted, NSError *error) { if (!granted) { NSLog(@"User rejected access to his account."); } else { NSArray *twitterAccounts = [store accountsWithAccountType:twitterAccountType]; if ([twitterAccounts count] &gt; 0) { ACAccount *account = [twitterAccounts objectAtIndex:0]; NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; [params setObject:@"1" forKey:@"include_entities"]; NSURL *url = [NSURL URLWithString:@"http://api.twitter.com/1/statuses/home_timeline.json"]; TWRequest *request = [[TWRequest alloc] initWithURL:url parameters:params requestMethod:TWRequestMethodGET]; [request setAccount:account]; [request performRequestWithHandler: ^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { if (!responseData) { NSLog(@"%@", error); } else { NSError *jsonError; NSArray *timeline = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&amp;jsonError]; self.timelineTwiter = timeline; if (timeline) { NSDictionary* tweets0 = [timeline objectAtIndex:0]; NSLog(@"%@", [tweets0 objectForKey:@"text"]); NSLog(@"%@", [[tweets0 objectForKey:@"user"] objectForKey:@"screen_name"]); NSDictionary* tweets1 = [timeline objectAtIndex:1]; NSLog(@"%@", [tweets1 objectForKey:@"text"]); NSLog(@"%@", [[tweets1 objectForKey:@"user"] objectForKey:@"screen_name"]); NSDictionary* tweets2 = [timeline objectAtIndex:2]; NSLog(@"%@", [tweets2 objectForKey:@"text"]); NSLog(@"%@", [[tweets2 objectForKey:@"user"] objectForKey:@"screen_name"]); } else { NSLog(@"%@", jsonError); } } }]; } } }]; } -(IBAction)refreshTimeline:(id)sender { [self fetchData]; } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 0; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [self.timelineTwiter count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; } id userTimeline = [self.timelineTwiter objectAtIndex:[indexPath row]]; cell.textLabel.text = [userTimeline objectForKey:@"text"]; cell.detailTextLabel.text = [userTimeline valueForKeyPath:@"user.name"]; return cell; } #pragma mark - Table view delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { } - (void)viewDidLoad { [super viewDidLoad]; [self fetchData]; // Do any additional setup after loading the view, typically from a nib. } - (void)viewWillAppear:(BOOL)animated { [self fetchData]; [super viewWillAppear:animated]; } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } @end </code></pre> <p>but it never loads the data into the table view, any help?</p> <p>Side note:</p> <p>I am using it with interface builder. </p> <p>&amp; Ideally i'd like to make a custom cell so i could work out the layout each cell, so if you know of any good sites which will show how to do that, that'd also be a big hand.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload