Objective-C 클래스에서 함수를 호출하고 있습니다. Swift 클래스의 배열을 Objective-C 함수로 전달합니다. 여기 Swift에서 NSArray를 Objective-C 함수로 전달
내가 블록을dispatch_sync(dispatch_get_main_queue(), ^{
self.ParsingArray = [[NSMutableArray alloc]init]; //array that contains the objects.
for (int i=0; i != [jsonObject count]; i++) {
for (int j=0; j != 1; j++) {
//NSLog(@"%@", [[jsonObject objectAtIndex:i] objectAtIndex:j]);
[self.ParsingArray addObject:[[jsonObject objectAtIndex:i] objectAtIndex:j]];
//Parse the JSON here...
//NSLog(@"Parsing Array - %@",self.ParsingArray);
stringArray = [self.ParsingArray copy];
[table reloadData];
}
}
});
나는이 무엇입니까 있던 목표 - C 함수 내부 스위프트
var videosAutoCompletion:[String] = []
completeSearch.autocompleteSegesstions(searchText, self.tableView, self.videosAutoCompletion)
목표 - C 기능
-(void)autocompleteSegesstions : (NSString *)searchWish :(UITableView*)table :(NSArray*)stringArray
내 코드입니다 다음 행에 대한 오류.
변수 (실종 __block 유형 지정자) 할당 할 수없는 라인에서
stringArray = [self.ParsingArray copy];
이 오류를 해결하는 StackOverflow 질문이 두 개 있습니다. 그것은 스위프트와 관련이 없습니다. "블록"(Swift에서 "클로저"에 대한 Objective-C 이름)을 사용하는 것과 관련이 있습니다. [메소드의 변수를 사용할 때 [블록 외부의 변수를 블록 외부에 할당]] (https://stackoverflow.com/q/7962721/1107226) 및 [ "변수를 할당 할 수 없습니다 (__block 유형 지정자가 누락되었습니다)"오류 메서드 블록의 선언] (https://stackoverflow.com/q/36573957/1107226) – leanne