ios - Adding NSString to NSMutableString -
i want add multiple nsstrings yo nsmutablestring construct list of strings.
this code in method takes nsdictionary , grabs value out of - stores in nsstring, there append string nsmutablestring. when running method first time works. however, when call method again, replaces last string in nsmutablestring.
here code:
nsstring *userid = [nsstring stringwithformat:@"%@,", parameters[@"userid"]]; self.alluserids = [nsmutablestring string]; [self.alluserids appendstring:userid]; can tell me doing wrong?
self.alluserids declared strong.
this:
self.alluserids = [nsmutablestring string]; is creating new mutable string. should done once, before want use mutable string, , not done again until want restart (because recreating mutable string destroys old instance had).
Comments
Post a Comment