开发者

Simple Twitter iPhone xCode problem

Just a quick question, I'm currently working through a tutorial on making a Twitter client for iPhone, nothing special just trying to figure ou开发者_StackOverflowt a bit more about xcode before buying books etc to learn about it

http://www.yousendit.com/download/UFVxQ3Q1TlFTSUJFQlE9PQ

That is a link to my current file, it is saying that I have undeclared my username and password and I would greatly appreciate any light that anyone can shed on my particular problem

:) Thanks guys

Phil


Username and Password are not objects. Here is the code he is talking about.

- (IBAction) postTwitter: (id)sender{

    TwitterRequest * t = [[TwitterRequest alloc] init];
    t.username = username.text;
    t.password = password.text;

    [t statuses_update:tweetmessage.text delegate:self requestSelector:@selector(status_updateCallback:)];
}

Your TwitterRequest object has a username and password property, so that is fine. But username and password are not local objects to this class. What you need to do is either:

- (IBAction) postTwitter: (id)sender{

TwitterRequest * t = [[TwitterRequest alloc] init];
t.username = @"USERNAME HERE"
t.password = @"PASSWORD HERE"

[t statuses_update:tweetmessage.text delegate:self requestSelector:@selector(status_updateCallback:)];  

}

OR you need to declare IBOutlets for 2 UITextField in your XIB and connect them. Like so.

Header File:

        #import <UIKit/UIKit.h>


    @interface TweetViewController : UIViewController {


        IBOutlet UITextField *tweetmessage;
        IBOutlet UITextField *username;
            IBOutlet UITextField *password;
    }

- (IBAction) postTwitter: (id) sender;
- (IBAction) login;

@end

If you do this you can leave your code as it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜