我需要能夠顯示開關是否打開或關閉警報以及其他細節,所有細節顯示都很好,但是當我嘗試添加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];
}
非常感謝! – AbdelElrafa
有什麼方法可以將換行符添加到警報中的字符串中嗎? – AbdelElrafa