post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['SWIFT_VERSION'] = '3.2' end end end
NSFontAttributeName --- .font //或者NSAttributedStringKey.font NSForegroundColorAttributeName --- .foregroundColor //NSAttributedStringKey.foregroundColor NSStrikethroughStyleAttributeName --- .strikethroughStyle //NSAttributedStringKey.strikethroughStyle //字符串类型的,添加rawValue NSAttributedStringKey.font.rawValue //等等等等.......... //大部分类似以下,涉及富文本的方法均已改为了NSAttributedStringKey类型 addAttributes(_ attrs: [NSAttributedStringKey : Any] = [:], range: NSRange)
struct RecordModel {
/// 定义一个闭包
var action: (() -> ())?
var height = 10
self.action = {
self.height = 20
//Closure cannot implicitly capture a mutating self parameter报错
}
}
struct RecordModel {
/// 定义一个闭包
var action: ((_ inSelf: inout RecordModel) -> ())?
var height = 10
self.action = { (inSelf) in
inSelf.height = 20
}
}
struct RecordModel {
/// 定义一个闭包
var action: (() -> ())?
var height = 10
let selfPointer = UnsafeMutablePointer(&self)
self.action = {
selfPointer.pointee.height = 20
}
}
extension UIViewController {
public override class func initialize() {//此处报错
//此处省略100行代码
}
}
extension UIViewController {
public override class func initializeOnceMethod() {
//此处省略100行代码
}
}
//在AppDelegate的方法中调用:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
//此处省略100行代码
UIViewController.initializeOnceMethod()
}
extension UITableView {
struct once{
static var onceTaken:Int = 0
}
dispatch_once(&once.onceTaken) { () -> Void in
//在这里dispatch_once就会报错
//此处省略1000000行代码
}
}
extension DispatchQueue {
private static var _onceTracker = [String]()
public class func once(token: String, block: () -> ()) {
objc_sync_enter(self)
defer {
objc_sync_exit(self)
}
if _onceTracker.contains(token) {
return
}
_onceTracker.append(token)
block()
}
func async(block: @escaping ()->()) {
self.async(execute: block)
}
func after(time: DispatchTime, block: @escaping ()->()) {
self.asyncAfter(deadline: time, execute: block)
}
}
DispatchQueue.once(token: "tableViewOnce") {
print( "Do This Once!" )
}
private let _onceToken = NSUUID().uuidString
DispatchQueue.once(token: _onceToken) {
print( "Do This Once!" )
}
func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [Any]!, from connection: AVCaptureConnection!) func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputSampleBuffer sampleBuffer: CMSampleBuffer!, from connection: AVCaptureConnection!)
func metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection) func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection)
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有