Array
append(_:) vs append(contentsOf:) append : 하나의 element를 배열 맨 뒤에 추가해준다 var numbers = [1, 2, 3, 4, 5] numbers.append(100) print(numbers) // Prints "[1, 2, 3, 4, 5, 100]" append(contentsOf): 여러개의 elements를 배열 맨 뒤에 추가 해준다. var numbers = [1, 2, 3, 4, 5] numbers.append(contentsOf: 10...15) print(numbers) // Prints "[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]" 출처 : https://developer.apple.com/documentation..
2022. 12. 21.
NSDictionary
// 방법 1 NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"value1", @"key1", @"value2", @"key2", nil]; // 방법 2 NSDictionary *dictionary = @{@"key", @"value"}; dictionary 배열에서 원하는 key의 value 개수 필터링 list : [ { "age" : 3, "grade" : "A" }, { "age" : 32, "grade" : "B" }, { "age" : 14, "grade" : "C" }, { "age" : 6, "grade" : "A" } ] 위와 같은 형식의 배열이라고 해보자, grade별 value counting하여 원하는 결과는 다..
2022. 11. 4.