iOS Objective-C 阻止警告:控制到达非空函数的结尾

iOS Objective-C blocks warning: Control reaches end of non-void function

我正在尝试使用 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

非void函数的ind在哪里?据我了解,我的方法是无效的...

在你的方法中你说你 return 一个指向 void (void *) 的指针。

因此,您的方法期望您 return 在函数末尾指向 void 的指针。

更改为 (void) 应该没问题。

编辑

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