RumeTimeiOS DeveloperiOS 开发

Swift 3.0Runtime 获取系统class属性

2016-07-23  本文已影响91人  mmaoyudi

因为有写API有改动,所以小写一下,如果以前的一些方法在Swift3.0里没发用了,可以去下面这个官方的API变动文档去看看

https://developer.apple.com/library/prerelease/content/releasenotes/General/watchOS30APIDiffs/Swift/Swift.html

var count : UInt32 = 0;        
    let list = class_copyPropertyList(UIPageControl.classForCoder(),&count)
    for i in 0..<count
    {
        let aa = list?[Int(i)]
        let cc = property_getName(aa)
      
//下面这个方法就是新加的,删掉了以前的
//String.fromCString(_: UnsafePointer<CChar>) -> String? [static]
        let name = String.init(cString:cc!)

//这样写也是同样的效果
        let name1 = String.init(utf8String : cc!)!
        print(name)
        print(name1)
            }
上一篇下一篇

猜你喜欢

热点阅读