您的位置:首页 > 移动开发 > IOS开发

iOS开发小记(十一)

2016-03-08 11:05 330 查看

ATS

http://www.baidu.com 需要配置ATS
https://www.baidu.com 不需要
Specifically, with ATS enabled, HTTP connections must use HTTPS (RFC 2818). Attempts to connect using insecure HTTP fail. Furthermore, HTTPS requests must use best practices for secure communications

宏定义

NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_BEGIN和NS_ASSUME_NONNULL_END。在这两个宏之间的代码,所有简单指针对象都被假定为nonnull,因此我们只需要去指定那些nullable的指针。

面对对象

封装、继承、多态

父类指向子类的指针,会因子类的不同而不同。

多态-重写、重载。OC不支持重载。

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellWithIdentifier];
cell指针就有多态

setter和getter

重写一个NSString类型的,retain方式声明name属性的setter和getter方法

-(void)settetName:(NSString *)name{
  if(_name){
  [_name release];
}
  _name = [name retain];
}
-(NSString *)getterName{
return [[_name retain]autorelease];
}


类别和延展

类别是把类的实现方法分散到不同的文件中 也可以给类扩展新方法

延展是给类添加私有方法 只为自己类所见 所使用

运行时机制

class_addProperty 与 class_addIvar

/// An opaque type that represents a method in a class definition.
typedef struct objc_method *Method;

类定义的方法类型

/// An opaque type that represents an instance variable.
typedef struct objc_ivar *Ivar;

实例对象的变量

/// An opaque type that represents a category.
typedef struct objc_category *Category;

类别

/// An opaque type that represents an Objective-C declared property.
typedef struct objc_property *objc_property_t;

类声明的变量

APP架构

网络层 - 数据层 - 逻辑业务层 - 显示层

盈盈的例子:

json - oc类 - 按照业务组合数据 - MVVM架构绑定显示

透明的导航栏

[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];

NSURL

fileURLWithPath
和URLWithPath

+ (id)URLWithString:(NSString *)URLString

Parameters

URLString

The string with which to initialize the NSURL object. Must be a URL that conforms to RFC 2396. This method parses URLString according to RFCs 1738 and 1808. (To create NSURL objects for file system paths, usefileURLWithPath:isDirectory: instead.)

+ (id)fileURLWithPath:(NSString *)path

Parameters

path

The path that the NSURL object will represent. path should be a valid system path. If path begins with a tilde, it must first be expanded with stringByExpandingTildeInPath. If path is a relative path, it is treated as being relative to the current working directory.

Passing nil for this parameter produces an exception.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: