Iqbal Khan
Iqbal Khan

Reputation: 4617

implicit conversion of an indirect pointer to an objective-c pointer to 'nsstring *' is disallowed with arc

i am keep getting this error on given below line. but i am unable to understand how to fix it. please guide me what is the problem. I know this is something with transition guide to ARC but i am unable to understand how to fix it. return [self isUnique:ioValue forKey:@"serverId"];

- (BOOL)validateServerId:(id *)ioValue error:(NSError **)outError {
//   DLog(@"%@",__strong ioValue);
//  NSString *__strong a=ioValue;
return [self isUnique:ioValue forKey:@"serverId"];
}

- (BOOL)isUnique:(NSString *)value forKey:(NSString *)key{

if([key isEqualToString:@"serverId"])
{
    NSFetchRequest * fetch = [[NSFetchRequest alloc] init];
    [fetch setEntity:[NSEntityDescription entityForName:[self.entity name]
                                 inManagedObjectContext:self.managedObjectContext]];

    NSPredicate *predicate = [NSPredicate
                              predicateWithFormat:@"serverId = %@",value];

    fetch.predicate = predicate;

    NSError *error = nil;
    NSUInteger count = [self.managedObjectContext
                        countForFetchRequest:fetch error:&error];

    if (count > 1) {
        // Produce error message...

        // Failed validation:
        return NO;
    }


}


return YES;
}

Upvotes: 3

Views: 4960

Answers (3)

Iqbal Khan
Iqbal Khan

Reputation: 4617

the solution is that add * before value because there coming the address and i am passing address by adding * now i am passing value on that address

return [self isUnique:*ioValue forKey:@"serverId"];

Upvotes: -1

Gyanendra Singh
Gyanendra Singh

Reputation: 1483

However id type is used for generic object (when your are not sure about it's type) replace the argument type from id to NSString

**** From ****
- (BOOL)validateServerId:(id *)ioValue error:(NSError **)outError;

**** To ****
- (BOOL)validateServerId:(NSString *)ioValue error:(NSError **)outError;

Hope this may help!

Upvotes: 2

Eric Qian
Eric Qian

Reputation: 2256

Remove * here (id *)ioValue or replace it with (NSString *)ioValue

Upvotes: 1

Related Questions