Author Topic: Device Name for iOS (iPhone, iPad, iPod Touch)  (Read 10215 times)

Offline blackway

  • Mr. Polyvector
  • ***
  • Posts: 186
    • View Profile
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...




« Last Edit: 2011-Jan-27 by Kitty Hello »

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: IOS Device Name?
« Reply #1 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

 
« Last Edit: 2011-Jan-27 by Kitty Hello »

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 930
  • KodeSource
    • View Profile
    • KodeSource
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]

Offline Moebius

  • Dr. Type
  • ****
  • Posts: 315
    • View Profile
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.
« Last Edit: 2011-Jan-28 by Serpent »
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 930
  • KodeSource
    • View Profile
    • KodeSource
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]

Offline michael

  • Mc. Print
  • *
  • Posts: 25
    • View Profile
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