private lazy var textField: UITextView = {
let fontSize: CGFloat = 16
let tv = UITextView()
tv.font = UIFont.systemFont(ofSize: fontSize)
tv.textAlignment = .center
var text = NSMutableAttributedString[......]
private lazy var textField: UITextView = {
let fontSize: CGFloat = 16
let tv = UITextView()
tv.font = UIFont.systemFont(ofSize: fontSize)
tv.textAlignment = .center
var text = NSMutableAttributedString[......]
如何encode:
let urlStrEncode = urlStr.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)
或者
let urlStrEncode = urlStr.stringByAddingPercentEncodingWithAllowedCharacters( NSCharacterSet.URLQueryAllowedCharacterSet())
顺道再贴下如何decode:
let[......]
如果使用了UINavigationViewController,在iOS7后,默认的子viewcontroller会跑到navvc的底下,遮挡一部分,解决方法是设置:
class BaseViewController: UIViewController {
override func viewDidLoad() {
// make vc top edge start from navigation bar's bottom
self.edges[......]
其实和Java很类似的,浅拷贝要实现用NSCopying,深拷贝要实现NSMutableCopying,举个例子:
摘抄自:http://stackoverflow.com/questions/11329754/is-this-a-reasonable-pattern-for-implementing-nsmutablecopying
// BBMovie.h
@interface BBMovie : NSObject < NSCopying, NSMutableCopyin[......]