사용자가 액세서리 버튼을 클릭 할 때마다 변수 "resultStringID"를 두 번째 뷰 "DetailViewController"에 "RootViewController"에서 전달하는 방법이 필요합니다. accessoryButtonTappedForRowWithIndexPath 메서드에 대한 내 코드는 다음과 같습니다accessoryButtonTappedForRowWithIndexPath 메서드에서 인스턴스화 된 NSMutableString을 다른 뷰로 전달하는 방법
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
processSelected = [array objectAtIndex:indexPath.row];
//realstatusSelected = [processStatusarray objectAtIndex:indexPath.row];
//NSLog(@"Real selected status is %@", realstatusSelected);
NSLog(@"combinedString at index is %@", processSelected);
NSMutableString * resultStringID = [NSMutableString stringWithCapacity:processSelected.length];
NSScanner *scanner = [NSScanner scannerWithString:processSelected];
//define the allowed characters, here only all numbers are allowed
NSCharacterSet *allowedChars = [NSCharacterSet characterSetWithCharactersInString:@"1234567890"];
while ([scanner isAtEnd] == NO) {
NSString *buffer;
if ([scanner scanCharactersFromSet:allowedChars intoString:&buffer]) {
[resultStringID appendString:buffer];
} else {
[scanner setScanLocation:([scanner scanLocation] + 1)];
}
}
//Trim off the last 3 characters if the string is larger than 4 characters long
if ([resultStringID length] > 4)
resultStringID = [resultStringID substringToIndex:[resultStringID length] - 3];
도움이 정말 감사드립니다! :)
고맙습니다. 그것은 간단하고 우아한 해결책이었다 :) –