KVC 的 容错方法
来源:互联网 发布:知乎 感情 精华贴 编辑:程序博客网 时间:2024/06/01 18:08
#pragma mark KVC容错方法
-(void)setValue:(id)value forUndefinedKey:(NSString *)key{
NSLog(@"fwefwefwefwefwef23222\n\n\n\n\n");
if ([key isEqualToString:@"IsOnlyXuanZuo"]) {
NSString *str = [NSString stringWithFormat:@"%@", value ];
self.IsOnlyXuanZuo = value;
}
if ([key isEqualToString:@"IsToBeAboutTo"]) {
NSString *str = [NSString stringWithFormat:@"%@", value ];
self.IsToBeAboutTo = value;
}
}
/********************** 分隔符 **********************/
//
// CinemaList.h
// UI11_作业01展示影院位置
//
// Created by Rickie on 15/11/27.
// Copyright (c) 2015年 Rickie. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface CinemaList : NSObject
/**
* 电影院的地址
*/
@property (nonatomic, copy) NSString *address;
/**
* 电影院名称
*/
@property (nonatomic, copy) NSString *cinemaName;
/**
* 城市名
*/
@property (nonatomic, copy) NSString *cityName;
/**
* 编号
*/
@property (nonatomic, copy) NSString *ID;
/**
* 纬度
*/
@property (nonatomic, copy) NSString *latitude;
/**
* 经度
*/
@property (nonatomic, copy) NSString *longitude;
/**
* 电话号码
*/
@property (nonatomic, copy) NSString *telephone;
/**
* 交通线路
*/
@property (nonatomic, copy) NSString *trafficRoutes;
//初始化方法和便利构造器
-(id)initWithDictionary:(NSDictionary *)dictionary;
+(CinemaList *)cinemaListWithDictionary:(NSDictionary *)dictionary;
@end
/********************** 分隔符 **********************/
//
// CinemaList.m
// UI11_作业01展示影院位置
//
// Created by Rickie on 15/11/27.
// Copyright (c) 2015年 Rickie. All rights reserved.
//
#import "CinemaList.h"
@implementation CinemaList
-(void)dealloc
{
[_address release];
[_cinemaName release];
[_cityName release];
[_ID release];
[_latitude release];
[_longitude release];
[_telephone release];
[_trafficRoutes release];
[super dealloc];
}
#pragma mark 初始化方法
-(id)initWithDictionary:(NSDictionary *)dictionary
{
self = [super init];
if (self) {
//KVC 赋值方法 传值,将字典里的数据传入到类里的属性里面
[self setValuesForKeysWithDictionary:dictionary];
}
return self;
}
#pragma mark 遍历构造器
+(CinemaList *)cinemaListWithDictionary:(NSDictionary *)dictionary
{
CinemaList *cinemaList = [[CinemaList alloc] initWithDictionary:dictionary];
return [cinemaList autorelease];
}
/********************** 当给的资料中有属性、key值为id时,使用容错处理 **********************/
#pragma mark KVC容错处理
-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
if ([key isEqualToString:@"id"]) {
self.ID = value;
}
}
@end
/********************** 分隔符 **********************/
- KVC 的 容错方法
- kvc机制与kvc的常用方法
- 增强if-else容错性的方法
- swift: 方法的重载/重写/KVC构造
- 简洁的对参数容错的javascript方法
- php 的简单存在 (魔术方法作用之一:容错)
- KVC调用方法列表
- Objective-C ,KVC研究,几种属性赋值的方法
- weblogic的容错性
- 容错系统的概念
- JSON的容错机制
- MapReduce的容错性
- MapReduce的容错机制
- hadoop的容错机制
- Hadoop的容错性
- MapReduce的容错机制
- dubbo的容错模式
- MapReduce的容错机制
- N皇后问题
- 整数转化成字符串; 字符串转换为整数
- mina总结
- node 可视化调试(支持监控文件变化)
- 0-1背包问题
- KVC 的 容错方法
- 如何从服务端下载的文件保存到SD卡
- LintCode 螺旋矩阵 (新解法)
- Scala: Under The Hood of Hello World
- 活了20年多了才知道!蜂蜜十大鲜见真相吓掉小命
- Android 动画杂谈 (三)
- 单源最短路径
- UI-之plist文件解析
- 链表反转的几种形式