简体   繁体   English

xcode 4.2目标c中的警告

[英]warnings in xcode 4.2 objective c

i created an iPad application, in which i am fetching data from URL, when i write this code it shows me this warning initWithContentsOfURL is deprecated 我创建了一个iPad应用程序,在其中我从URL提取数据,当我编写此代码时,它向我显示此警告initWithContentsOfURL is deprecated

here is the code snippet, 这是代码片段,

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]; 

also in tableView it shows me this warning, initWithFrame:reuseIdentifier: is deprecated 同样在tableView中,它向我显示此警告, initWithFrame:reuseIdentifier: is deprecated

here is the code snippet, in which i am creating one label inside each row 这是代码段,其中我在每一行内创建一个标签

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;

and when i call multiple parametrized method, it shows me this warning, 当我调用多个参数化方法时,它向我显示此警告,

method name: 方法名称:

-(void)recentquote:(NSString *)sym:(int)i

call syntex: 调用syntex:

[self recentquote:l3:i];

warning: 警告:

Instance method '-recentquote::' not found (return type default to 'id')'

Help me guys !! 帮帮我!

Thanks In Advance !! 提前致谢 !!

instead of 代替

initWithContentsOfURL 

use: 采用:

initWithContentsOfFile:encoding:error: 

or 要么

initWithContentsOfFile:usedEncoding:error: 

instead of 代替

initWithFrame:reuseIdentifier: 

use: 采用:

initWithStyle:reuseIdentifier:

And you should change the declaration of: 您应该更改以下内容的声明:

-(void)recentquote:(NSString *)sym:(int)i

to: 至:

-(void)recentquote:(NSString *)sym someArg:(int)i

Seems like you are really new to objective-c and iPad development, I strongly recommand you to read: https://stackoverflow.com/questions/332039/getting-started-with-iphone-development 似乎您真的是对Objective-C和iPad开发的新手,我强烈建议您阅读: https : //stackoverflow.com/questions/332039/getting-started-with-iphone-development

the call syntax should be 调用语法应为

[self recentquote:l3 :i];

(note at the space in between), I suggest renaming your function anyway. (请注意中间的空格),无论如何,我建议重命名您的函数。

when it say it's deprecated, it simply means some time in the future, Apple might remove this method all together, it's not longer supported. 当它说它已被弃用时,它只是意味着将来的某个时间,Apple可能会一起删除此方法,不再受支持。 So change your 所以改变你的

cell = [[[UITableViewCell alloc]initWithFrame:CGRectZero reuseIdentifier:CellIdentifier]autorelease];

to

cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                            reuseIdentifier:CellIdentifier] autorelease];

Check the documentation for available style and what it means 检查文档中可用的样式及其含义

EDIT : 编辑:

I suggest changing it, maybe to 我建议更改它,也许

- (void)recentQuote:(NSString *)quote withIndex:(int)index; 

then to call it use 然后称之为

[self recentQuote:@"OK" withIndex:2];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM