Tôi đang làm việc trên ứng dụng Universal & muốn truy cập các giá trị được lưu trữ trong tệp app-info.plist trong mã của tôi.iOS: Truy cập các biến app-info.plist trong mã
Lý do: tôi nhanh chóng một UIViewController động từ một kịch bản sử dụng:
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
self = [storyboard instantiateViewControllerWithIdentifier:@"ExampleViewController"];
Bây giờ, có tên storyboard @ "MainStoryboard_iPhone" ở trên là xấu xí.
tôi muốn làm một cái gì đó như:
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:appInfo.mainStoryboardBaseNamePhone bundle:nil];
self = [storyboard instantiateViewControllerWithIdentifier:@"ExampleViewController"];
nơi appInfo có lẽ có thể là một NSDictionary của tất cả các giá trị trong app-info.plist
Là đàn ông được tioned bởi @Answerbot trong bài đăng này: http: //stackoverflow.com/a/4059118/1210822: "CFBundleVersion đã được định lại thành Phiên bản và Phiên bản là CFBundleShortVersionString", vì vậy bây giờ để truy xuất số phiên bản từ plist, chúng tôi cần phải sử dụng : NSString * version = [[NSBundle mainBundle] objectForInfoDictionaryKey: @ "CFBundleShortVersionString"]; – sonoshin