我想從result.text
動態添加字符串值,我希望以這種方式顯示它[@"17052648287",@"17052607335"]
而不會丟失值。我該怎麼做?在objc中動態添加字符串
NSMutableArray *strings = [@[@"17052648287",@"17052607335"] mutableCopy];
添加上編碼
- (void)captureResult:(ZXCapture *)capture result:(ZXResult *)result{
if (!result) return;
if(self.hasScannedResult == NO)
{
//Scan Result, added into array
NSString *scanPackage = [NSString stringWithFormat:@"%@", result.text];
scanLists = [NSMutableArray new];
[scanLists addObject:scanPackage];
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
NSMutableArray *strings = [[NSMutableArray alloc]init];
strings = [@[result.text] mutableCopy];
[preferences setObject:strings forKey:@"strings"];
NSMutableArray *stringsArray = [preferences objectForKey:@"strings"];
for (NSString *string in stringsArray) {
NSLog(@"string: %@", string);
}
你想展示以這種方式最終輸出'[@「17052648287」,@「17052607335」]' –
你能解釋一下嗎? results.text等結構你只是想要在數組中的所有字符串? – Bhanupriya
@ Anbu.Karthik yes – Nurburgring