class_copyPropertyList not working in Swift 5. Whats the reason?How can I deal with @objc inference deprecation with #selector() in Swift 4?What is a typedef enum in Objective-C?Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?Do Swift-based applications work on OS X 10.9/iOS 7 and lower?How to call Objective-C code from Swift#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?iOS 8 UITableView separator inset 0 not working

How could Nomadic scholars effectively memorize libraries worth of information

Does academia have a lazy work culture?

Is a topological space considered to be a class in set theory?

Trapped in an ocean Temple in Minecraft?

Can the term divorcée apply if a woman has not only divorced, but subsequently remarried?

Is it legal for private citizens to "impound" e-scooters?

How to check what is edible on an alien world?

How can I say in Russian "they cannot make the tournament attractive by itself"?

If my pay period is split between 2 calendar years, which tax year do I file them in?

Make AES more secure by randomising the blocks in an encrypted file

How to handle academic references for US PhD program, when I have been out of academia for a (very) long time?

DC motor does not work using PWN or Digital pins

How to tar a list of directories only if they exist

What is this spacecraft tethered to another spacecraft in LEO (vintage)

How do I stop my characters falling in love?

Why do all my history books divide Chinese history after the Han dynasty?

Finding minimum time for vehicle to reach to its destination

Is my employer paying me fairly? Going from 1099 to W2

Why do planes need a roll motion?

Why is 'n' preferred over "n" for output streams?

Use cases for M-0 & C-0?

Word for showing a small part of something briefly to hint to its existence or beauty without fully uncovering it

Are the named pipe created by `mknod` and the FIFO created by `mkfifo` equivalent?

Request for a Latin phrase as motto "God is highest/supreme"



class_copyPropertyList not working in Swift 5. Whats the reason?


How can I deal with @objc inference deprecation with #selector() in Swift 4?What is a typedef enum in Objective-C?Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?Do Swift-based applications work on OS X 10.9/iOS 7 and lower?How to call Objective-C code from Swift#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?iOS 8 UITableView separator inset 0 not working






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















class_copyPropertyList is giving empty properties in Swift 5 and it was working correct in Swift 3



 extension NSObject 

func toDictionary(from classType: NSObject.Type) -> [String: Any]

var propertiesCount : CUnsignedInt = 0
let propertiesInAClass = class_copyPropertyList(classType, &propertiesCount)
let propertiesDictionary : NSMutableDictionary = NSMutableDictionary()

for i in 0 ..< Int(propertiesCount)
let property = propertiesInAClass?[i]
let strKey = NSString(utf8String: property_getName(property)) as String?
if let key = strKey
propertiesDictionary.setValue(self.value(forKey: key), forKey: key)


return propertiesDictionary as! [String : Any]




// call this for NSObject subclass



 let product = Product()
let dict = product.toDictionary(from: Product.self)
print(dict)









share|improve this question






















  • Probably due to NSObject @objc inference deprecation. You'll want to mark the stored properties as @objc, or if you want all members (including methods) exposed to Obj-C, mark the class as @objcMembers. See for example stackoverflow.com/q/44390378/2976878

    – Hamish
    Mar 26 at 18:55












  • Unrelated, but there's no need to pass in the classType parameter, you can use type(of: self) instead. Also note that you need to call free(propertiesInAClass) before the end of the method to prevent a memory leak.

    – Hamish
    Mar 26 at 19:01












  • how can we get property list by using type of

    – Aditya Sharma
    Mar 26 at 19:02











  • class_copyPropertyList(type(of: self), &propertiesCount)

    – Hamish
    Mar 26 at 19:04











  • po class_copyPropertyList(type(of: User.self), &count) error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0). The process has been returned to the state before expression evaluation.

    – Aditya Sharma
    Mar 26 at 19:05

















0















class_copyPropertyList is giving empty properties in Swift 5 and it was working correct in Swift 3



 extension NSObject 

func toDictionary(from classType: NSObject.Type) -> [String: Any]

var propertiesCount : CUnsignedInt = 0
let propertiesInAClass = class_copyPropertyList(classType, &propertiesCount)
let propertiesDictionary : NSMutableDictionary = NSMutableDictionary()

for i in 0 ..< Int(propertiesCount)
let property = propertiesInAClass?[i]
let strKey = NSString(utf8String: property_getName(property)) as String?
if let key = strKey
propertiesDictionary.setValue(self.value(forKey: key), forKey: key)


return propertiesDictionary as! [String : Any]




// call this for NSObject subclass



 let product = Product()
let dict = product.toDictionary(from: Product.self)
print(dict)









share|improve this question






















  • Probably due to NSObject @objc inference deprecation. You'll want to mark the stored properties as @objc, or if you want all members (including methods) exposed to Obj-C, mark the class as @objcMembers. See for example stackoverflow.com/q/44390378/2976878

    – Hamish
    Mar 26 at 18:55












  • Unrelated, but there's no need to pass in the classType parameter, you can use type(of: self) instead. Also note that you need to call free(propertiesInAClass) before the end of the method to prevent a memory leak.

    – Hamish
    Mar 26 at 19:01












  • how can we get property list by using type of

    – Aditya Sharma
    Mar 26 at 19:02











  • class_copyPropertyList(type(of: self), &propertiesCount)

    – Hamish
    Mar 26 at 19:04











  • po class_copyPropertyList(type(of: User.self), &count) error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0). The process has been returned to the state before expression evaluation.

    – Aditya Sharma
    Mar 26 at 19:05













0












0








0








class_copyPropertyList is giving empty properties in Swift 5 and it was working correct in Swift 3



 extension NSObject 

func toDictionary(from classType: NSObject.Type) -> [String: Any]

var propertiesCount : CUnsignedInt = 0
let propertiesInAClass = class_copyPropertyList(classType, &propertiesCount)
let propertiesDictionary : NSMutableDictionary = NSMutableDictionary()

for i in 0 ..< Int(propertiesCount)
let property = propertiesInAClass?[i]
let strKey = NSString(utf8String: property_getName(property)) as String?
if let key = strKey
propertiesDictionary.setValue(self.value(forKey: key), forKey: key)


return propertiesDictionary as! [String : Any]




// call this for NSObject subclass



 let product = Product()
let dict = product.toDictionary(from: Product.self)
print(dict)









share|improve this question














class_copyPropertyList is giving empty properties in Swift 5 and it was working correct in Swift 3



 extension NSObject 

func toDictionary(from classType: NSObject.Type) -> [String: Any]

var propertiesCount : CUnsignedInt = 0
let propertiesInAClass = class_copyPropertyList(classType, &propertiesCount)
let propertiesDictionary : NSMutableDictionary = NSMutableDictionary()

for i in 0 ..< Int(propertiesCount)
let property = propertiesInAClass?[i]
let strKey = NSString(utf8String: property_getName(property)) as String?
if let key = strKey
propertiesDictionary.setValue(self.value(forKey: key), forKey: key)


return propertiesDictionary as! [String : Any]




// call this for NSObject subclass



 let product = Product()
let dict = product.toDictionary(from: Product.self)
print(dict)






ios objective-c swift iphone mirror






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 26 at 18:50









Aditya SharmaAditya Sharma

3012 silver badges15 bronze badges




3012 silver badges15 bronze badges












  • Probably due to NSObject @objc inference deprecation. You'll want to mark the stored properties as @objc, or if you want all members (including methods) exposed to Obj-C, mark the class as @objcMembers. See for example stackoverflow.com/q/44390378/2976878

    – Hamish
    Mar 26 at 18:55












  • Unrelated, but there's no need to pass in the classType parameter, you can use type(of: self) instead. Also note that you need to call free(propertiesInAClass) before the end of the method to prevent a memory leak.

    – Hamish
    Mar 26 at 19:01












  • how can we get property list by using type of

    – Aditya Sharma
    Mar 26 at 19:02











  • class_copyPropertyList(type(of: self), &propertiesCount)

    – Hamish
    Mar 26 at 19:04











  • po class_copyPropertyList(type(of: User.self), &count) error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0). The process has been returned to the state before expression evaluation.

    – Aditya Sharma
    Mar 26 at 19:05

















  • Probably due to NSObject @objc inference deprecation. You'll want to mark the stored properties as @objc, or if you want all members (including methods) exposed to Obj-C, mark the class as @objcMembers. See for example stackoverflow.com/q/44390378/2976878

    – Hamish
    Mar 26 at 18:55












  • Unrelated, but there's no need to pass in the classType parameter, you can use type(of: self) instead. Also note that you need to call free(propertiesInAClass) before the end of the method to prevent a memory leak.

    – Hamish
    Mar 26 at 19:01












  • how can we get property list by using type of

    – Aditya Sharma
    Mar 26 at 19:02











  • class_copyPropertyList(type(of: self), &propertiesCount)

    – Hamish
    Mar 26 at 19:04











  • po class_copyPropertyList(type(of: User.self), &count) error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0). The process has been returned to the state before expression evaluation.

    – Aditya Sharma
    Mar 26 at 19:05
















Probably due to NSObject @objc inference deprecation. You'll want to mark the stored properties as @objc, or if you want all members (including methods) exposed to Obj-C, mark the class as @objcMembers. See for example stackoverflow.com/q/44390378/2976878

– Hamish
Mar 26 at 18:55






Probably due to NSObject @objc inference deprecation. You'll want to mark the stored properties as @objc, or if you want all members (including methods) exposed to Obj-C, mark the class as @objcMembers. See for example stackoverflow.com/q/44390378/2976878

– Hamish
Mar 26 at 18:55














Unrelated, but there's no need to pass in the classType parameter, you can use type(of: self) instead. Also note that you need to call free(propertiesInAClass) before the end of the method to prevent a memory leak.

– Hamish
Mar 26 at 19:01






Unrelated, but there's no need to pass in the classType parameter, you can use type(of: self) instead. Also note that you need to call free(propertiesInAClass) before the end of the method to prevent a memory leak.

– Hamish
Mar 26 at 19:01














how can we get property list by using type of

– Aditya Sharma
Mar 26 at 19:02





how can we get property list by using type of

– Aditya Sharma
Mar 26 at 19:02













class_copyPropertyList(type(of: self), &propertiesCount)

– Hamish
Mar 26 at 19:04





class_copyPropertyList(type(of: self), &propertiesCount)

– Hamish
Mar 26 at 19:04













po class_copyPropertyList(type(of: User.self), &count) error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0). The process has been returned to the state before expression evaluation.

– Aditya Sharma
Mar 26 at 19:05





po class_copyPropertyList(type(of: User.self), &count) error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0). The process has been returned to the state before expression evaluation.

– Aditya Sharma
Mar 26 at 19:05












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55364358%2fclass-copypropertylist-not-working-in-swift-5-whats-the-reason%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55364358%2fclass-copypropertylist-not-working-in-swift-5-whats-the-reason%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴