2

I have read the answer to this question, Identify new iPhone model on xcode (5, 5c, 5s) and would like to add this as an NSString to my MFMailCompose. I have tried using this method but am not having any luck. Someone please help me.

Sorry I am new to Xcode.

                NSString *iOS           = [[UIDevice currentDevice] systemVersion];
                NSString *model         = [[UIDevice currentDevice] model];
                NSString *appVersionString = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
                NSString *name          = [[UIDevice currentDevice] name];
                NSString *appID=@" ";
                NSString *appStoreURL =[NSString stringWithFormat:@"https://itunes.apple.com/us/app/scanmarks/id926114469?ls=1&mt=8", appID];
                NSString *body  = [NSString stringWithFormat:@"I need help with\n\n\n----------\n Name: %@\nDevice: %@ (%@)\n Scanmarks Version: %@\n",name,model,iOS,appVersionString];

It currently shows:Current

I would like it to show the iPhone Device model like Tweetbot doesenter image description here

I have added the suggested and now have this:enter image description here enter image description here

Community
  • 1
  • 1
Harvey
  • 37
  • 5

2 Answers2

0

Harvey,

I built an open source tool that does exactly what you want. Feel free to use it or browse through the code to see how I accomplished what you're asking.

https://github.com/michaelpatzer/MPFeedbackMailComposeViewController

M-P
  • 4,909
  • 3
  • 25
  • 31
0

Using the link you you put in your question, if you just want it to say the iPhone platform you would just use this portion of their answer :

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 encoding:NSUTF8StringEncoding];

free(machine);

That will translate to iPhone7,2 etc. just pass the NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding]; string 'platform' into your message body

If you want to convert that to whatever string you want that's when the other portion comes into play. This is the only time you'll use the other part and all of the conversions in their answer:

NSString *convertPlatformToString = [self platformType:platform]);

Example for putting in mail message:

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 encoding:NSUTF8StringEncoding];

free(machine);

NSString *body = [NSString stringWithFormat:@"Platform is %@", platform];
soulshined
  • 9,612
  • 5
  • 44
  • 79
  • I have updated my question after adding your suggestions, does not seem to be working. – Harvey Mar 15 '15 at 19:17
  • @Harvey no your not listening , i know your new to Xcode but I said all you have to do is pass the `platform` string into your message body – soulshined Mar 15 '15 at 19:27
  • You don't need the `- (NSString *) platformType:(NSString *)platform` method unless you want to convert the model number into a string @Harvey see edited answer – soulshined Mar 15 '15 at 19:28