2013-10-13 6 views
1

배열의 개체를 경고보기에서 반환 된 텍스트로 바꾸려고합니다.테이블보기에서 색인 경로 검색

지금까지 내가 가지고 :

int selected = indexPath.row; 

내 alertview 위임 방법

.

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ 
    if (alertView.tag == 1) { 
     [myMutableArray replaceObjectAtIndex:selected withObject:[[alertView textFieldAtIndex:0] text]]; 
     [_tableView reloadData]; 
    } 
} 

내가

'NSInteger'(일명 '긴')에서 ('* 긴'일명) 'NSInteger *'로 지정하는 포인터 변환

호환되지 않는 정수

+0

코드 전체입니까? NSMutableArray를 어디에서 초기화합니까? 가능한 경우 모든 코드를 게시하십시오. – wigging

+0

질문을 이해하는 데 도움이 되었다면 답을 표시하십시오. – wigging

답변

0

의 오류없이 점점 계속 나머지 코드가 어떤 모양인지 알면 ViewController.m 파일에서이 코드를 시도 할 수 있습니다. "OK"버튼을 누르면 레이블 텍스트를 설정하고 변경 가능한 배열의 객체를 경고보기의 텍스트로 바꿉니다. 당신이 jQuery과 사용하고있는 것 같습니다 때문에

#import "ViewController.h" 

@interface ViewController() <UIAlertViewDelegate> 

@property (strong,nonatomic) NSMutableArray *mutArray; 
@property (weak,nonatomic) IBOutlet UILabel *label; 

@end 

@implementation ViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    NSArray *array = @[@"item1",@"item2",@"item3"]; 
    self.mutArray = [[NSMutableArray alloc] init]; 
    self.mutArray = [array mutableCopy]; 
} 

- (IBAction)showAlert:(id)sender { 

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"My Alert Example" 
                message:@"message here" 
                delegate:self 
              cancelButtonTitle:@"Cancel" 
              otherButtonTitles:@"OK",nil]; 

    alert.alertViewStyle = UIAlertViewStylePlainTextInput; 

    [alert show]; 
} 

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { 

    int selected = 1; 

    if (buttonIndex != alertView.cancelButtonIndex) { 
     NSLog(@"ok button"); 
     UITextField *textField = [alertView textFieldAtIndex:0]; 
     self.label.text = textField.text; 
     [self.mutArray replaceObjectAtIndex:selected withObject:textField.text]; 
     NSLog(@"mutArray is %@",self.mutArray); 
    } else { 
     NSLog(@"cancel button"); 
    } 
} 

@end 

, 귀하의 경우는 int selected = indexPath.row 대신 int selected = 1 것이다.

2

오류는 NSInteger 변수 앞에 *을 넣었 기 때문에 발생합니다.