Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios ARC禁止明确发送';保留';_Ios_Objective C_Amazon Web Services - Fatal编程技术网

Ios ARC禁止明确发送';保留';

Ios ARC禁止明确发送';保留';,ios,objective-c,amazon-web-services,Ios,Objective C,Amazon Web Services,我正在尝试使用AmazonAPI for iOS来处理Objective-C中Amazon网站的登录。 但是,当我实现AMZNAuthorizeUserDelegate时,会收到以下错误消息: ARC禁止“保留”的显式消息发送 我以前从未使用过Objective-C,因此如果有人能帮助我编写代码,我将不胜感激 这是我的密码: #import <LoginWithAmazon/LoginWithAmazon.h> #import "AMZNAuthorizeUserDelegate.h

我正在尝试使用AmazonAPI for iOS来处理Objective-C中Amazon网站的登录。 但是,当我实现
AMZNAuthorizeUserDelegate
时,会收到以下错误消息:

ARC禁止“保留”的显式消息发送

我以前从未使用过Objective-C,因此如果有人能帮助我编写代码,我将不胜感激

这是我的密码:

#import <LoginWithAmazon/LoginWithAmazon.h>
#import "AMZNAuthorizeUserDelegate.h"
#import "AMZNGetProfileDelegate.h"

@implementation AMZNAuthorizeUserDelegate

- (id)initWithParentController:(ViewController*)aViewController {
    if(self = [super init]) {
        parentViewController = [aViewController retain];
}

return self;
}

- (void)requestDidSucceed:(APIResult *)apiResult {
  AMZNGetProfileDelegate* delegate = [[[AMZNGetProfileDelegate alloc]         initWithParentController:parentViewController] autorelease];
[AIMobileLib getProfile:delegate];
}

- (void)requestDidFail:(APIError *)errorResponse {
NSString *message = errorResponse.error.message;
// Your code when the authorization fails.

[[[[UIAlertView alloc] initWithTitle:@"" message:[NSString
                                                      stringWithFormat:@"User authorization failed with message: %@",
                                                  errorResponse.error.message] delegate:nil
                   cancelButtonTitle:@"OK"otherButtonTitles:nil] autorelease] show];
}

@end
#导入
#导入“AMZNAuthorizeUserDelegate.h”
#导入“AmzGetProfileDelegate.h”
@实现AMZNAuthorizeUserDelegate
-(id)initWithParentController:(ViewController*)aViewController{
if(self=[super init]){
parentViewController=[aViewController保留];
}
回归自我;
}
-(void)requestDidSuccess:(apireult*)apireult{
AmzGetProfileDelegate*delegate=[[AmzGetProfileDelegate alloc]initWithParentController:parentViewController]自动释放];
[AIMobileLib getProfile:委托];
}
-(void)requestDidFail:(APIRROR*)errorResponse{
NSString*message=errorResponse.error.message;
//授权失败时您的代码。
[[[UIAlertView alloc]initWithTitle:@]消息:[NSString]
stringWithFormat:@“用户授权失败,消息为:%@”,
errorResponse.error.message]委托:无
取消按钮提示:@“确定”其他按钮提示:无]自动释放]显示];
}
@结束

错误消息正确:对
retain
的调用不再有效

,或ARC,于2011年通过iOS 5和Mac OS X 10.7添加到Objective-C语言中。在ARC之前,您必须通过调用
-retain
-release
-autorelease
等方法手动管理应用程序的内存使用情况。ARC在编译时自动管理这些调用,因此不允许您自己调用它们

正如@Paulw11在他的评论中提到的,您应该能够将该行替换为

parentViewController = aViewController

ARC将自动执行正确的操作。

这似乎是一个非常古老的代码。ARC不需要保留/释放,ARzc已经存在多年。您可以将该行替换为
parentViewController=aViewController
可能重复的代码,否则我会怀疑该旧代码。除了需要为ARC进行更新外,它还可能使用不推荐使用的框架,否则就会过时。AWS仍然得到积极支持。你应该寻找更新过的示例代码,而不是使用那些过时的代码。@Duncac:同意,但之前处理过糟糕的第三方库,有时真的没有更新的东西,你必须用处理过的那只手来工作。同样值得注意的是:OP使用的不是AWS SDK,而是“使用Amazon登录”SDK。