iOS Question How To run This code

hanyelmehy

Active Member
Licensed User
Longtime User
I want to run this code and get result in B4I
B4X:
#import <sys/utsname.h> // import it in your header or implementation file.

NSString* deviceName()
{
    struct utsname systemInfo;
    uname(&systemInfo);

    return [NSString stringWithCString:systemInfo.machine
                              encoding:NSUTF8StringEncoding];
}
How to do this
 

JanPRO

Well-Known Member
Licensed User
Longtime User
Hi,

use inline Objc code:
B4X:
Sub GetDeviceModel As String
    Dim NaObj As NativeObject = Me
    Return NaObj.RunMethod("Get",Null).AsString
    #If OBJC
    #import <sys/utsname.h>
    -(NSString*)Get{
        struct utsname systemInfo;
        uname(&systemInfo);
        return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
    }
    #end if
End Sub

Jan
 
Upvote 0
Top