Device Name for iOS (iPhone, iPad, iPod Touch)

Previous topic - Next topic

blackway

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...





Kitty Hello

#1
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



Slydog

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.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Moebius

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.
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Slydog

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?
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

michael

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