2013-09-22 2 views
-2

다른 세부 정보와 함께 경고 스위치에서 스위치가 켜지거나 꺼져 있는지를 표시 할 수 있어야합니다. 모든 세부 정보가 잘 표시되지만 notificationStatus 문자열을 추가하려고하면 오류가 발생합니다. "선언되지 않은 식별자의 사용 'notificationStatus'"NSString을 사용하여 다른 문자열을 표시 하시겠습니까?

-(void) procrastinationNotificationSwitchOnOrOff { 

    if (_procrastinationNotificationSwitch.on) { 
     _notificationOnOffLabel.text = @"Procrastination Notification On"; 
     NSString *notificationStatus = @"NOTIFICATION ON"; 
     NSLog(notificationStatus); 
    } 
    else { 
     _notificationOnOffLabel.text = @"Procrastination Notification Off"; 
     NSString *notificationStatus = @"NOTIFICATION OFF"; 
     NSLog(notificationStatus); 
    } 
} 


-(void) presentMessage:(NSString *)message { 
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Class Stuff" message:message delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; 
    [alert show]; 

} 

-(void) notificationStatus:(NSString *)stat { 
    NSString *status = [NSString stringWithFormat:@"%@", stat]; 

} 


-(IBAction)returnKeyButton:(id)sender { 
    [sender resignFirstResponder]; 

    NSString *classNameString = self.className.text; 
    NSLog(classNameString); 
    NSString *assignmentTitleString = self.assignmentTitle.text; 
    NSLog(assignmentTitleString); 
    NSString *assignmentDescriptionString = self.assignmentDescription.text; 
    NSLog(assignmentDescriptionString); 
    NSString *totalStrings = [NSString stringWithFormat:@"%@ %@ %@ %@", classNameString, assignmentTitleString, assignmentDescriptionString, notificationStatus]; 
    NSLog(totalStrings); 

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init]; 
    dateFormatter.timeZone = [NSTimeZone defaultTimeZone]; 
    dateFormatter.timeStyle = NSDateFormatterShortStyle; 
    dateFormatter.dateStyle = NSDateFormatterShortStyle; 

    NSString *dateTimeString = [dateFormatter stringFromDate: dateTimePicker.date]; 
    NSLog(@"Alarm Set Button Tapped : %@", dateTimeString); 
    [self presentMessage:totalStrings]; 
} 


- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
    [_procrastinationNotificationSwitch addTarget:self action:@selector(procrastinationNotificationSwitchOnOrOff) forControlEvents:UIControlEventValueChanged]; 
} 

답변

0

당신은 당신의 방법 procrastinationNotificationSwitchOnOrOff에서 지역 변수 notificationStatus 있습니다. notificationStatus도 있습니다. 속성 또는 인스턴스 변수 notificationStatus가 없습니다.

속성을 추가하십시오. notificationStatus. 메소드 notificationStatus를 제거합니다. self.notificationStatus를 사용하여 항상 notificationStatus를 읽고 쓴다. 문제 해결됨.

+0

감사합니다. – AbdelElrafa

+0

경고 문자열에 줄 바꿈을 추가하는 방법이 있습니까? – AbdelElrafa

0

는 당신이 그것을 로컬 변수를 만드는 것이 더겠습니까 방법을

-(void) notificationStatus:(NSString *)stat { 
    NSString *status = [NSString stringWithFormat:@"%@", stat]; 

} 

를함으로써 일을 혼동하고 생각하고 당신이 그것을 사용의 getter 및 setter를 조작합니다.

관련 문제