GLBasic forum

Main forum => FAQ => Topic started by: blackway on 2011-Jan-26

Title: Device Name for iOS (iPhone, iPad, iPod Touch)
Post by: blackway on 2011-Jan-26
Hi to all...
I'd like to know if is there a way to get the device name of any Iphone\Ipod touch? (the name that you see under Settings\General\Information in your Iphone)
Thanks!
Cheers...




Title: Re: IOS Device Name?
Post by: Kitty Hello on 2011-Jan-27
make an .m file and add that to your project (on XCode)

Code (glbasic) Select

char gSomePath[1024]="";

const char* iPhoneDeviceName()
{
NSString *deviceUDID = [[UIDevice currentDevice] name];
strcpy(gSomePath, [deviceUDID UTF8String]);
return gSomePath;
}



In GLB do:
Code (glbasic) Select

?IFDEF IPHONE
IMPORT "C" const char* iPhoneDeviceName()
name$ = iPhoneDeviceName()
?ENDIF


Title: Re: Device Name for iOS (iPhone, iPad, iPod Touch)
Post by: Slydog on 2011-Jan-27
I've never done any inline code yet, and was wondering why the above couldn't be changed to something like this:

Code (glbasic) Select
GLOBAL device_name$ = "unknown"

?IFDEF IPHONE
INLINE
   char gSomePath[1024]="";

   NSString *deviceUDID = [[UIDevice currentDevice] name];
   strcpy(gSomePath, [deviceUDID UTF8String]);
   strcpy(device_name_Str, gSomePath);

ENDINLINE
?ENDIF


Or something close to that.
Can INLINE include Objective C code?  If not, then I can see why you need a separate ".m" file that is compiled by XCode.
Title: Re: Device Name for iOS (iPhone, iPad, iPod Touch)
Post by: Moebius on 2011-Jan-28
Even if you can put pure Objective-C code in your GLB program the compiler won't know about all of Apple's stuff (NSString, UIDevice, currentdevice, and whatever else they inherit from) unless you copy all of the header files that define everything over from XCode... hence it's no doubt easier just to compile the functions that need Apple's classes, functions, and whatever else in XCode with simple IMPORT commands in GLB.
Title: Re: Device Name for iOS (iPhone, iPad, iPod Touch)
Post by: Slydog on 2011-Jan-28
Thanks, I guess that makes sense.

So, would it be possible for Gernot to add a special 'INLINE' command that doesn't touch the contents, but leaves it intact in the generated C code?  That way you could add Objective C (or whatever) that doesn't get interpreted, but gets copied into the C code for Xcode to compile.  Or does GLBasic's compile do something different other than simply creating plain C source code for Xcode to handle?
Title: Re: Device Name for iOS (iPhone, iPad, iPod Touch)
Post by: michael on 2011-Dec-31
nice example for the UUID but who can I get the version of the ios?

exist there an example for that or can someone help. Thanks