iOS Question GUID

Discussion in 'iOS Questions' started by daxydoggie, Jul 16, 2015.

  1. daxydoggie

    daxydoggie Member Licensed User

    What is the B4i equivalent of the following code to generate a GUID?

    Sub GetGUID() As String
    Dim r As Reflector
    r.Target = r.RunStaticMethod("java.util.UUID", "randomUUID", Null, Null)
    Return r.RunMethod("toString")
    End Sub
  2. imbault

    imbault Well-Known Member Licensed User

    Do you mean, you need a unique iOS device ID?

    If your answer = yes Then
    Sub GetVendorIdentifier As String
    Dim no As NativeObject
       no = no.Initialize(
    Dim id As Object = no.GetField("identifierForVendor").GetField("UUIDString")
    Return id
    End Sub
    Else If you need a random ID = yes Then
    Sub RandomUUID As String
    Dim no As NativeObject
    Return no.Initialize("NSUUID").RunMethod("UUID"Null).RunMethod("UUIDString"Null).AsString
    End Sub
    End If
  3. daxydoggie

    daxydoggie Member Licensed User