iPhone sdk: how to solve this warnings
hi i am working with Twitter, in this there will be two class, for showing tweet in table
view and retrieving string for table view like user photos, screen name, username and date
one class is MyTweetViewController.h //I am impor开发者_运维技巧ting the Tweet class also
and next one is Tweet.h class
//this line i am getting warning i.e NO initWithTweetDictionary method not found,
Tweet *tweet =[[Tweet alloc] initWithTweetDictionary:tweetDict];
- -(void)statusesReceived:(NSArray *)statuses forRequest:(NSString *)connectionIdentifier
// this is delegate for MGTwitter for retrieving information of user
{
NSLog(@"Statuses Receives: %@",statuses);
{
tweetArray = [[NSMutableArray alloc] init];
for(NSDictionary *tweetDict in statuses)
{
Tweet *tweet =[[Tweet alloc] initWithTweetDictionary:tweetDict];// here i am getting
warring i.e NO initWithTweetDictionary method not found,
[tweetArray addObject:tweet];
[tweet release];
}
}
[self.tweetsTableView reloadData];
}
////Tweet.h
#import <UIKit/UIKit.h>
@interface Tweet : NSObject {
NSDictionary *contentsTweet;
}
-(NSString*)userName;
-(NSString*)tweet;
-(NSString*)image_url;
-(NSString*)created_at;
@end
///Tweet.m
#import "Tweet.h"
@implementation Tweet
-(id)initWithTweetDictionary:(NSDictionary*)_contentsTweet {
if(self = [super init]) {
contentsTweet = _contentsTweet;
[contentsTweet retain];
}
return self;
}
-(NSString*)userName {
NSDictionary * dic = (NSDictionary*)[contentsTweet objectForKey:@"user"];
return [dic objectForKey:@"name"];
}
-(NSString*)tweet {
return [contentsTweet objectForKey:@"text"];
}
-(NSString*)image_url {
NSDictionary * dic = (NSDictionary*)[contentsTweet objectForKey:@"user"];
return [dic objectForKey:@"profile_image_url"];
}
- (void)dealloc {
[contentsTweet release];
[super dealloc];
}
@end
Please suggest me
Thank you
in Tweet.h you have to declare -(id)initWithTweetDictionary:(NSDictionary*)_contentsTweet;
in order to make the warning dissappear.
@interface Tweet : NSObject {
NSDictionary *contentsTweet;
}
-(id)initWithTweetDictionary:(NSDictionary*)_contentsTweet;
-(NSString*)userName;
-(NSString*)tweet;
-(NSString*)image_url;
-(NSString*)created_at;
@end
精彩评论