MOJO Type Mismatch - Charles Yeoman's code

I was checking out the UUID code from Charles Yeomans MOJO code and it noticed it wouldn’t compile. I don’t write much introspection code so the error isn’t obvious to me.

Relevant Code

Evidently it’s a type mismatch but from what I can tell they’re both “typeinfo.”


I cannot open the two links pointing to, but my assumption would be that you have a Using Xojo.Introspection clause somewhere in code or in the navigator, while Mojo is not based on the new framework.

  Dim result As String
  #If TargetCocoa
    Soft Declare Function NSClassFromString Lib "Cocoa" ( clsName As cfstringref ) As ptr
    Soft Declare Function UUID Lib "Cocoa" selector "UUID" ( clsRef As ptr ) As ptr
    Soft Declare Function UUIDString Lib "Cocoa" selector "UUIDString" ( obj_id As ptr ) As cfstringref
    Dim classPtr As Ptr = NSClassFromString( "NSUUID" )
    Dim NSUUID As ptr = UUID( classPtr )
    result = UUIDString( NSUUID )
  #ElseIf TargetWin32
    Const kLibName = "win32.Rpcrt4"
    Soft Declare Function UUIDCreate Lib kLibName alias "UuidCreate" ( ByRef uuid As WindowsUUID ) As Integer
    Soft Declare Function UUIDToString Lib kLibName alias "UuidToStringA" ( ByRef inUUID As WindowsUUID, ByRef outString As CString ) As Integer
    Dim uuid As WindowsUUID // Structure [x(15) as UInt8]
    Dim out As CString
    result = out
    result = result.DefineEncoding( Encodings.UTF8 )
    result = result.Uppercase
  Return result

That’s strange. They open up fine for me. Are you on mobile?

Thanks for the code Dave. However, I was looking for something that would work across all the platforms including the Web (linux) and mobile.

At least iOS won’t give you access to the UUID anymore for security reasons.

You may have to settle for the MAC address.

[quote=300146:@Michel Bujardet]At least iOS won’t give you access to the UUID anymore for security reasons.

You may have to settle for the MAC address.[/quote]
MIchel … would you care to expand upon that statement?
there is nothing stopping you from generating a UUID with iOS, just need the correct band-aid (I mean declare) for Xojo

In Swift and ObjC it is REALLY difficult to to

    let uuid = UUID().uuidString // THIS IS NOT XOJO CODE... DO NOT PASTE INTO YOU XOJO PROJECT!!!!!!

I think he’s talking about the device UUID.

ah… good point… my brain (and the code I posted) was to CREATE a UUID

I was talking indeed about the device UUID. Besides, getting that information from a Web app is AFAIK completely impossible anyway.

Change that one line into

dim TestableClasses() as Introspection.TypeInfo
TestableClasses.Append GetTypeInfo(mojo.UUID)

Norman FTW.