objective c - Access items from system_profiler plist -
i have plist file generated system_profiler -xml command: 
how can cpu_type or machine_name , store them in nsstrings?
i tried many methods, converting file json, couldn't elements.
example:

str nil
the path seems like:
root \ 0 \ _items \ 0 \ cpu_type root \ 0 \ _items \ 0 \ current_processor_speed ...
there no enumeration here, should able straight keys, don't know how.
thank you!
[arr valueforkey:@"cpu_type"] not work because arr array, not dictionary. access value want, try this
nsdictionary *rootdictionary = [nsarray arraywithcontentsoffile:filepath][0]; nsdictionary *itemsdictionary = rootdictionary[@"_items"][0]; nsstring *cputype = itemsdictionary[@"cpu_type"]; note [0] shorthand [array objectatindex:0], , [@"key"] short [dictionary objectforkey:@"key"]
getting machine_name done in same fashion
nsstring *machinename = itemsdictionary[@"machine_name"];
Comments
Post a Comment