[C/OC的那点事儿]Objective-C实现学生成绩管理系统(5)
来源:未知 责任编辑:责任编辑 发表时间:2013-12-18 11:33 点击:次
p> [studentArray sortUsingDescriptors:[NSArray arrayWithObject:sortByAge]];
p>
p>
p> }
p> else if ([key isEqualToString:@"score"])
p> {
p> NSSortDescriptor *sortByScore = [NSSortDescriptor sortDescriptorWithKey:@"score" ascending:ascending];
p>
p> [studentArray sortUsingDescriptors:[NSArray arrayWithObject:sortByScore]];
p>
p>
p> }
p>
p>
p>}
p>
p>-(void)writeToFile
p>{
p> NSString *path = [NSString stringWithFormat:@"/Users/len/Desktop"];
p> NSLog(@"请输入你所要写入的文件名字:");
p> char sfilename[20];
p> scanf("%s",sfilename);
p>
p> NSString *filename = [NSString stringWithUTF8String:sfilename];
p> NSString *filepath = [path stringByAppendingPathComponent:filename];
p>
p> NSData *data = [NSKeyedArchiver archivedDataWithRootObject:studentArray ];
p>
p> [data writeToFile:filepath atomically:YES];
p>
p>
p>
p>
p>}
p>
p>-(void)readFromFile
p>{
p> NSString *path = [NSString stringWithFormat:@"/Users/len/Desktop"];
p> NSLog(@"请输入你所要读取的文件名字:");
p> char sfilename[20];
p> scanf("%s",sfilename);
p>
p> NSString *filename = [NSString stringWithUTF8String:sfilename];
p> NSString *filepath = [path stringByAppendingPathComponent:filename];
p>
p> //NSMutableData *data = [[NSMutableData alloc]initWithContentsOfFile:filepath];
p>
p> NSMutableData *Data = [NSMutableData dataWithContentsOfFile:filepath];
p> self.studentArray = [NSKeyedUnarchiver unarchiveObjectWithData:Data];
p>
p>
p>}
p>
p>-(void)motifyStudent
p>{
p> NSLog(@"请输入你要修改的同学的学号:");
p> int studentID;
p> scanf("%d",&studentID);
p>
p> for (Student *stu in studentArray) {
p> if (stu.stuID == studentID) {
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>