[英]warnings in xcode 4.2 objective c
我创建了一个iPad应用程序,在其中我从URL提取数据,当我编写此代码时,它向我显示此警告initWithContentsOfURL is deprecated
这是代码片段,
NSString *mainstr;
NSURL *urlr=[NSURL URLWithString:@"http://abc.com/default.aspx?id=G"];
NSURLRequest *reqr=[NSURLRequest requestWithURL:urlr];
[webViewq loadRequest:reqr];
mainstr=[[NSMutableString alloc]initWithContentsOfURL:urlr];
同样在tableView中,它向我显示此警告, initWithFrame:reuseIdentifier: is deprecated
这是代码段,其中我在每一行内创建一个标签
static NSString *CellIdentifier=@"Cell";
if(cell == nil){
cell=[[[UITableViewCell alloc]initWithFrame:CGRectZero reuseIdentifier:CellIdentifier]autorelease];
CGRect frame;
frame.origin.x = 0;
frame.origin.y = 0;
frame.size.height = 40;
frame.size.width = 180;
UILabel *capitalLabelI = [[UILabel alloc] initWithFrame:frame];
capitalLabelI.tag = CapitalTag;
capitalLabelI.font=[UIFont systemFontOfSize:16.0];
}
capitalLabelI.text=[@" " stringByAppendingString:[a objectAtIndex:indexPath.row]];
return cell;
当我调用多个参数化方法时,它向我显示此警告,
方法名称:
-(void)recentquote:(NSString *)sym:(int)i
调用syntex:
[self recentquote:l3:i];
警告:
Instance method '-recentquote::' not found (return type default to 'id')'
帮帮我!
提前致谢 !!
代替
initWithContentsOfURL
采用:
initWithContentsOfFile:encoding:error:
要么
initWithContentsOfFile:usedEncoding:error:
代替
initWithFrame:reuseIdentifier:
采用:
initWithStyle:reuseIdentifier:
您应该更改以下内容的声明:
-(void)recentquote:(NSString *)sym:(int)i
至:
-(void)recentquote:(NSString *)sym someArg:(int)i
似乎您真的是对Objective-C和iPad开发的新手,我强烈建议您阅读: https : //stackoverflow.com/questions/332039/getting-started-with-iphone-development
调用语法应为
[self recentquote:l3 :i];
(请注意中间的空格),无论如何,我建议重命名您的函数。
当它说它已被弃用时,它只是意味着将来的某个时间,Apple可能会一起删除此方法,不再受支持。 所以改变你的
cell = [[[UITableViewCell alloc]initWithFrame:CGRectZero reuseIdentifier:CellIdentifier]autorelease];
至
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier] autorelease];
编辑:
我建议更改它,也许
- (void)recentQuote:(NSString *)quote withIndex:(int)index;
然后称之为
[self recentQuote:@"OK" withIndex:2];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.