hope all are having a good day. I had implemented a device check files base on something I ran into here in stack overflow, i haven't been able to find the original post to past it here. If i happen to come across, I will reference it.
This used to work great on the previous xcode 4.x but for xcode 5 I get this error.
Expected method to read dictionary element not found on object of type 'NSDictionary *' NSString *deviceName = commonNamesDictionary[machineName];
I manage to find this but it was for iOS 5 to iOS6 How to enable the new Objective-C object literals on iOS?
The code implemented is as follows. Obviously this was until iphone 5 not sure how to add the new phone archs.
.h implementation
#import <Foundation/Foundation.h>
#import <sys/utsname.h> //to check if its a iphone 4s or iphone 5
@interface deviceCheck : NSObject
+(NSString*)deviceModelName;
@end
.m implementation
#import "deviceCheck.h"
@implementation deviceCheck
* device checking method to tell the difference between devices */
+(NSString*)deviceModelName
{
struct utsname systemInfo;
uname(&systemInfo);
NSString *machineName = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
NSDictionary *commonNamesDictionary =
@{
@"i386": @"iPhone Simulator",
@"x86_64": @"iPad Simulator",
@"iPhone1,1": @"iPhone",
@"iPhone1,2": @"iPhone 3G",
@"iPhone2,1": @"iPhone 3GS",
@"iPhone3,1": @"iPhone 4",
@"iPhone4,1": @"iPhone 4S",
@"iPhone5,1": @"iPhone 5(GSM)",
@"iPhone5,2": @"iPhone 5(GSM+CDMA)",
@"iPad1,1": @"iPad",
@"iPad2,1": @"iPad 2(WiFi)",
@"iPad2,2": @"iPad 2(GSM)",
@"iPad2,3": @"iPad 2(CDMA)",
@"iPad2,4": @"iPad 2(WiFi Rev A)",
@"iPad2,5": @"iPad Mini(WiFi)",
@"iPad2,6": @"iPad Mini(GSM)",
@"iPad2,7": @"iPad Mini(GSM+CDMA)",
@"iPad3,1": @"iPad 3(WiFi)",
@"iPad3,2": @"iPad 3(GSM+CDMA)",
@"iPad3,3": @"iPad 3(GSM)",
@"iPad3,4": @"iPad 4(WiFi)",
@"iPad3,5": @"iPad 4(GSM)",
@"iPad3,6": @"iPad 4(GSM+CDMA)",
@"iPod1,1": @"iPod 1st Gen",
@"iPod2,1": @"iPod 2nd Gen",
@"iPod3,1": @"iPod 3rd Gen",
@"iPod4,1": @"iPod 4th Gen",
@"iPod5,1": @"iPod 5th Gen",
};
NSString *deviceName = commonNamesDictionary[machineName]; // <-- here is the issue
if (deviceName == nil) {
deviceName = machineName;
}
return deviceName;
}
@end
Anyone else has come across this issue?
In advance thanks for your help on this.