Wrote a method to save the search keyword, unexpectedly appeared title said Crash, from the semantics of this is probably the case: to a non-mutable object sent Mutable method
Here's how:
+ (void) Setusersearchdynamickeyword: (NSString *) Strkeyword
{
Nsmutablearray * searcharray = [[Nsuserdefaults Standarduserdefaults] Objectforkey:str_search_dynamic_array];
if (Searcharray = = nil)
{
Searcharray = [Nsmutablearray array];
}
[Searcharray Addobject:strkeyword];
[[Nsuserdefaults Standarduserdefaults] Setobject:searcharray Forkey:str_search_dynamic_array];
[[Nsuserdefaults standarduserdefaults] synchronize];
}
Can be sure that Searcharray is definitely nsmutablearray, then why still say to Nsmutablearray is not a mutable object it.
Online is to say that the objects returned from Nsuserdefault are fixed and cannot be modified. The specific reason is unknown, first recorded in this, and left behind to study the study.