gpt4 book ai didi

ios - iOS Objective-C阻止警告:控件到达非空函数的末尾

转载 作者:行者123 更新时间:2023-12-01 17:51:21 24 4
gpt4 key购买 nike

我正在尝试使用Objective-C块。我有方法:

- (void *)getObjectsWithSuccess:(void (^)(NSArray *objectives))success failure:(void (^)(NSError *error))failure;
{
NSMutableArray *objects = [[NSMutableArray alloc] init];

NSString *url = [URL_CONSTANT];

NSDictionary *parameters = @{@"username" : USERNAME_CONSTANT, @"password" : PASSWORD_CONSTANT};

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

[manager POST:url parameters:parameters

success:^(AFHTTPRequestOperation *operation, id responseObjects)
{
for (id responseObject in responseObjects)
{
NSString *title = [responseObject objectForKey:@"title"];
NSString *description = [responseObject objectForKey:@"description"];

Object *object = [[Object alloc] init];

objective.title = title;
objective.description = description;

[objects addObject:object];
}

success(objects);
}

failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
failure(error);
}];
}

当Xcode构建此方法时,我总是收到以下警告: control reaches end of non-void function
非无效函数的ind在哪里?据我了解,我的方法无效...

最佳答案

在您的方法中,您说您返回一个指向void (void *)的指针。

因此,您的方法期望您在函数末尾返回一个指向void的指针。

更改为(void),就可以了。

编辑

尽管您编辑了问题,但我认为您对该代码段仍然没有同样的问题。尝试查看代码中是否也有(void *)

关于ios - iOS Objective-C阻止警告:控件到达非空函数的末尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29631817/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com