20.04.2013 Views

Tutorial pratici per iPhone SDK v1.6 - Get a Free Blog

Tutorial pratici per iPhone SDK v1.6 - Get a Free Blog

Tutorial pratici per iPhone SDK v1.6 - Get a Free Blog

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Possiamo salvare e chiudere Interface Builder<br />

LEGGIAMO LA TIMELINE<br />

Iniziamo ad implementare il codice che deve leggere i tweet dalla nostra timeline. Apriamo il<br />

file “SampleTwitterClientViewController.m” ed inseriamo il seguente codice:<br />

1<br />

2<br />

3<br />

4<br />

5<br />

6<br />

7<br />

8<br />

9<br />

10<br />

11<br />

12<br />

13<br />

14<br />

15<br />

16<br />

17<br />

18<br />

19<br />

20<br />

21<br />

22<br />

#import "SampleTwitterClientViewController.h"<br />

#import "Tweet.h"<br />

@implementation SampleTwitterClientViewController<br />

@synthesize listaTweet, spinner;<br />

-(void)viewDidLoad{<br />

!<br />

! // Username e password <strong>per</strong> accedere a Twitter<br />

NSString *username = @"user_name";<br />

NSString *password = @"password";<br />

// Create a TwitterEngine and set our login details.<br />

twitterEngine = [[MGTwitterEngine alloc] initWithDelegate:self];<br />

[twitterEngine setUsername:username password:password];<br />

// <strong>Get</strong> updates from people the authenticated user follows.<br />

[twitterEngine getFollowedTimelineFor:username since:nil<br />

startingAtPage:0];<br />

! !<br />

! [spinner startAnimating];<br />

}<br />

Non preoccupatevi troppo di capire il codice, in quanto l’ho preso direttamente dall’esempio<br />

fornito con la classe “MGTwitterEngine”. Ricordatevi, comunque, di inserire i vostro dati <strong>per</strong> il<br />

login alla riga 11 e 12. Le righe seguenti, invece, servono <strong>per</strong> inizializzare l’elemento “twitterEngine”,<br />

che si occu<strong>per</strong>à di leggere la timeline di Twitter.<br />

Alla riga 21, inoltre, abbiamo avviato la rotella (che fermeremo quando la procedura di lettura e<br />

conversione dei dati sarà terminata).<br />

<strong>Tutorial</strong> <strong>pratici</strong> <strong>per</strong> <strong>iPhone</strong> <strong>SDK</strong>! 140

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!