If you've got an App in the App Store, or are planning to sell an app there, it might be a good idea to learn from somebody else's mistake.
#import <Foundation/Foundation.h>
@interface UIDevice (platform)
- (NSString *) platform;
- (NSString *) platformString;
@end
#import "UIDevice-Platform.h"
#include <sys/types.h>
#include <sys/sysctl.h>
@implementation UIDevice (platform)
- (NSString *) platform{
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithCString:machine];
free(machine);
return platform;
}
- (NSString *) platformString{
NSString *platform = [self platform];
if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 1G";
if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";
if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS";
if ([platform isEqualToString:@"iPod1,1"]) return @"iPod Touch 1G";
if ([platform isEqualToString:@"iPod2,1"]) return @"iPod Touch 2G";
if ([platform isEqualToString:@"i386"]) return @"iPhone Simulator";
return platform;
}
- (BOOL)supportsBluetoothNetworking {
NSString *platform = [self platform];
return !([platform isEqualToString:@"iPhone1,1"] || platform isEqualToString:@"iPod1,1"]);
}
@end
Note: Although you can create an Objective-C application without using nib files, doing so is very rare and not recommended. Depending on your application, avoiding the use of nib files can involve overriding large amounts of framework behavior to achieve the same results you would get using a nib file.I don't think Apple could be much clearer on this point. Apple and NeXT developers have been using Interface Builder for twenty-one years, longer than many programmers have been programming. I think, at this point, they've got a pretty good handle on how it works and when it should be used. It boggles my mind that there's even a debate on this issue. There's really no excuse for creating your user interface in code in the vast majority of situations. Using Interface Builder is faster and much easier to maintain.
It boils down to this: if MonoTouch and Adobe’s Applications for iPhone platform are no good, they will die. Developers who use them will sell fewer apps in the App Store. Objective-C developers will carry on developing apps in their preferred style and creating apps that sell well. But if the rival techniques are sound, everyone gets to write great iPhone apps, and the result is happy users, and an even wider adoption of the iPhone platform.Here's the key point missed. It doesn't boil down to that. If MonoTouch and Flash for iPhone are no good, they won't die for a reason James himself pointed out earlier in the same posting: the users don't know or care how the application was created. If MonoTouch and Flash applications are slow and crash or use gobs of memory or break under future versions of the iPhone OS, the end users aren't going to take away a negative impression of Adobe or Novell, they're going to think "Apple Sucks". They're going to blame the iPhone. It will affect the users' opinion of the individual developer, sure, but first and foremost it's going to affect the users' opinions of the iPhone as a platform.
Like me, many developers will welcome the chance to learn a new language and a new platform But many will just want to write an app and get it into the hands of their users as quickly as they can. (emphasis mine)Exactly. That's exactly what I have a problem with. Getting an app into a users hands as quickly as possible is not a virtue. Getting an app to the user when it's done, and good, and well-tested, and performing well is. I don't want this mentality. I want developers like Snappy Touch, who obsess over the user experience. I want developers like Imangi, Flipside 5, Tim Haines, and the countless others who cared enough to dive in and learn the platform, learn the language and tools, and deliver great user experiences on the iPhone despite having to learn to do it. I want developers who care. Developers who care, care enough to use the right tools and invest time learning about their platform and about the users of that platform.