iActiveRecord icon indicating copy to clipboard operation
iActiveRecord copied to clipboard

Attempt to mutate immutable object with appendFormat:

Open danpe opened this issue 11 years ago • 3 comments

Using the following lines:

    ARLazyFetcher* fetcher = team.users;
    User* asker = [self asker];
    if (asker != nil) {
        [fetcher where:@"'user'.'serverUserId' != %@", asker.serverUserId, nil];
        return fetcher.fetchRecords;
    }

crashed from Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempt to mutate immutable object with appendFormat:'

on

[fetcher where:@"'user'.'serverUserId' != %@", asker.serverUserId, nil];

danpe avatar Oct 20 '13 00:10 danpe

Could you add breakpoint to [fetcher where:... and print description of fetcher.whereStatement? Seems that whereStatement is not a mutable string.

AlexDenisov avatar Oct 20 '13 09:10 AlexDenisov

Printed the description:

Printing description of fetcher:
<ARLazyFetcher: 0x1287cc20>
Printing description of fetcher->whereStatement:
"Member"."teamId" = "1"

screenshot 2013-10-20 14 06 13

danpe avatar Oct 20 '13 17:10 danpe

@AlexDenisov it happens sometimes to me too, mutable objects become immutable. I guess you could secure this by using myObject = [myObject mutableCopy] where you feel like it could go wrong.

ghost avatar Nov 07 '13 20:11 ghost