存储在字典中的内容到判断输出时就为空
#import <Foundation/Foundation.h> #import "UserAdministration.h" @interface UsernameandPassword : NSObject @property(nonatomic,strong)NSString *Username; @property(nonatomic,strong)NSString *Password; @property(nonatomic,strong)UserAdministration *userAd; @property(nonatomic,strong)NSString *addvideoID; @property(nonatomic,strong)NSString *addvideoname; @property(nonatomic,strong)NSMutableDictionary *addv; -(void)UserSignin; -(void)FunctionSelection; -(id)initWithAddv:(NSMutableDictionary *)addv AddvideoID:(NSString *)addvideoID Addvideoname:(NSString *)addvideoname; @end
#import "UsernameandPassword.h" #define NSLog(FORMAT, ...) fprintf(stderr,"%s",[[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]) @implementation UsernameandPassword -(id)initWithAddv:(NSMutableDictionary *)addv AddvideoID:(NSString *)addvideoID Addvideoname:(NSString *)addvideoname{ self = [super init]; if (self) { self.addv = addv; self.addvideoID = addvideoID; self.addvideoname = addvideoname; } return self; } -(void)UserSignin{ //用户登录 NSLog(@"******************iOS学习系统登录界面******************\n"); NSLog(@"是否登录:\n1登录\n2不登录\n"); //登录选项 int LoginOptions = 0; scanf("%d",&LoginOptions); if (LoginOptions == 1) { //用户名 NSLog(@"请输入登录用户名:"); char buffer1[1000]; scanf("%s",buffer1); NSString * youname = [NSString stringWithUTF8String:buffer1]; //用户密码 NSLog(@"请输入登录密码:"); char buf2[1000]; scanf("%s",buf2); NSString * youpassword = [NSString stringWithUTF8String:buf2]; //判断输入的用户名和密码是否和注册时的一致 if(youname == self.userAd.flag && youpassword == self.userAd.fla){ NSLog(@"\n登录成功\n"); NSLog(@"******************iOS学习系统功能选择界面******************\n"); NSLog(@"请输入要选择的功能\n"); }else{ NSLog(@"用户名或密码错误,请重新输入\n"); [self UserSignin]; } }else{ NSLog(@"退出学习系统\n"); } } -(void)FunctionSelection{ NSMutableDictionary *addv = [[NSMutableDictionary alloc]init]; //登录后功能选择:1>1>2>1 这样就可以一直循环 //登录后操作 NSLog(@"1 观看iOS学习视频\n2 下载iOS学习资料\n3 直接退出\n"); //功能选择 int a = 1; int b = 0; while (a > b) { int Function = 0; scanf("%d",&Function); if (Function == 1) { NSLog(@"视频为空\n观看iOS学习视频中……\n请输入要选择的功能:\n"); NSLog(@"1 观看iOS学习视频\n2 下载iOS学习资料\n3 直接退出\n"); //观看视频 int WatchVideo = 0; scanf("%d",&WatchVideo); if (WatchVideo == 1) { NSLog(@"1 查询所有iOS视频\n2 通过ID选择播放某一iOS视频\n3 添加一个新的iOS视频\n4 删除某一iOS视频\n"); //通过ID播放视频 int IdPlay = 0; scanf("%d",&IdPlay); if (IdPlay == 1) { NSLog(@"观看iOS学习视频中……\n"); }else if (IdPlay == 2){ NSLog(@"请输入要选择观看的视频ID\n"); //播放ID视频 int VideoiD = 0; scanf("%d",&VideoiD); if (VideoiD == 1) { NSLog(@"你查找的视频不存在\n观看学习视频中……\n请输入要选择的功能:\n"); NSLog(@"1 观看iOS学习视频\n2 下载iOS学习资料\n3 直接退出\n"); }else if(VideoiD == self.addvideoID){ NSArray *str1 = [self.addv valueForKey:self.addvideoID]; NSLog(@"%@\n",str1); [self FunctionSelection]; } }else if (IdPlay == 3){ NSLog(@"请输入视频ID\n"); char adv[1000]; scanf("%s",adv); self.addvideoID = [NSString stringWithUTF8String:adv]; NSLog(@"请输入视频名称\n"); char advn[1000]; scanf("%s",advn); self.addvideoname = [NSString stringWithUTF8String:advn]; [addv setValue:self.addvideoname forKey:self.addvideoID]; NSLog(@"%@",addv); [self FunctionSelection]; }else if (IdPlay == 4){ NSLog(@"请输入需要删除的视频ID\n"); [addv removeObjectForKey:self.addvideoID]; [self FunctionSelection]; } } }else if (Function == 2){ NSLog(@"1 下载所有iOS视频\n2 通过ID选择下载某一iOS视频\n"); }else if (Function == 3){ NSLog(@"退出\n"); } a++; } } @end
67
收起
正在回答 回答被采纳积分+1
2回答
楼上大白
2017-11-30 19:38:43
#import <Foundation/Foundation.h> @interface UserAdministration : NSObject -(void)Userregistration; @property(nonatomic,strong)NSString *flag; @property(nonatomic,strong)NSString *fla; -(id)initWithFlag:(NSString *)flag Fla:(NSString *)fla; @end
#import "UserAdministration.h" #import "UsernameandPassword.h" #define NSLog(FORMAT, ...) fprintf(stderr,"%s",[[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]) @implementation UserAdministration -(id)initWithFlag:(NSString *)flag Fla:(NSString *)fla{ self = [super init]; if (self) { self.flag = flag; self.fla = fla; } return self; } //用户注册信息 -(void)Userregistration{ NSLog(@"请输入注册用户名:"); char buffer[1000]; scanf("%s",buffer); self.flag = [NSString stringWithUTF8String:buffer]; NSLog(@"请输入注册密码:"); char buf[1000]; scanf("%s",buf); self.fla = [NSString stringWithUTF8String:buf]; NSLog(@"注册成功\n"); } @end
iOS入门:基础语法与常用控件
- 参与学习 1337 人
- 提交作业 712 份
- 解答问题 1878 个
很多人都在疑问没有基础该怎么学习iOS开发?不用担心,本路径采用游戏关卡式的教学模式,并且以经典OC与最新Swift双重结合的教学内容,帮助大家快速掌握两种iOS开发语言基础,去掉“零”标签。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星