Присоединитесь к массиву в Objective C

Это зависит. Требуете ли вы, чтобы обновления вашего поля EGameState были упорядочены или нет?
Если они должны быть упорядочены, то блок synchronized (на this) является обязательным, если нет, то volatile достаточно.

128
задан Sophie Alpert 6 December 2013 в 09:56
поделиться

3 ответа

NSArray  *array1 = [NSArray arrayWithObjects:@"1", @"2", @"3", nil];
NSString *joinedString = [array1 componentsJoinedByString:@","];

componentsJoinedByString: will join the components in the array by the specified string and return a string representation of the array.

272
ответ дан 24 November 2019 в 00:36
поделиться

The method you are looking for is componentsJoinedByString.

NSArray  *a = [NSArray arrayWithObjects:@"1", @"2", @"3", nil];//returns a pointer to NSArray
NSString *b = [a componentsJoinedByString:@","];//returns a pointer to NSString
NSLog(@"%@", b); // Will output 1,2,3
17
ответ дан 24 November 2019 в 00:36
поделиться

NSArray class reference:

NSArray *pathArray = [NSArray arrayWithObjects:@"here",
    @"be", @"dragons", nil];
NSLog(@"%@",
    [pathArray componentsJoinedByString:@" "]);
6
ответ дан 24 November 2019 в 00:36
поделиться
Другие вопросы по тегам:

Похожие вопросы: