开发者

UIText Field and Labels

开发者 https://www.devze.com 2023-03-05 19:47 出处:网络
I know this is probably a simple question but I need your help. I\'m trying to make an app to decode an aeronautical message.I need to get the text from the text field and set the label to decode it i

I know this is probably a simple question but I need your help. I'm trying to make an app to decode an aeronautical message. I need to get the text from the text field and set the label to decode it into plain language. I.e. if the user insert 12310520 in the text field the label must be 31 december at 0520 a.m

thanks fro your help

I tried this but i'm getting Null:

NSString *data = [NSString stringWithFormat:@"%@", [date text]];// this come from the textfield---
NSDateFormatter *dateFormatter =[[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"MM-dd'at'HH:mm"];
NSDate *dateFromString=[[NSDate alloc]init];
dateFromSt开发者_开发技巧ring = [dateFormatter dateFromString:data];
   NSLog(@"%@", dateFromString);


you will have to use NSFormatter on your UITextField, then catch and separate the string up into month, day, time variables. Then you can perform something like a case/catch statement that checks your new strings and returns a what ever you want for each case. then just concatenate those strings back together and pass it to your label..

I would give you an example but my day is over and I'm back off home.. but I hope this gives you an idea as to how you might be able to do this... However if you wait someone else will likely provide a better solution.

0

精彩评论

暂无评论...
验证码 换一张
取 消