Skip to content
This repository has been archived by the owner on Nov 25, 2019. It is now read-only.

Attempt to mutate immutable object with appendFormat: #50

Open
danpe opened this issue Oct 20, 2013 · 3 comments
Open

Attempt to mutate immutable object with appendFormat: #50

danpe opened this issue Oct 20, 2013 · 3 comments

Comments

@danpe
Copy link
Contributor

danpe commented Oct 20, 2013

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];

@AlexDenisov
Copy link
Owner

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

@danpe
Copy link
Contributor Author

danpe commented Oct 20, 2013

Printed the description:

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

screenshot 2013-10-20 14 06 13

@ghost
Copy link

ghost commented Nov 7, 2013

@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.

danpe added a commit to danpe/iActiveRecord that referenced this issue Nov 7, 2013
…ov#50

Using stringWithFormat instead of appendFormat to fix issue AlexDenisov#50

Maybe we should change all mutable strings to normal strings and use string with format, but it may lower the performance.
AlexDenisov added a commit that referenced this issue Nov 8, 2013
Using stringWithFormat instead of appendFormat to fix issue #50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants