Skip to content

Instantly share code, notes, and snippets.

@rmanly
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save rmanly/ddab1df683672ea00ed4 to your computer and use it in GitHub Desktop.

Select an option

Save rmanly/ddab1df683672ea00ed4 to your computer and use it in GitHub Desktop.
first attempt at getting UUIDs in python
>>> import Foundation as F
>>> foo = F.NSUUID.UUID()
>>> print foo
<__NSConcreteUUID 0x7f9a78df73b0> 19AE1973-8C5C-40D7-BBE4-073F6EA3B0D5
>>> foo[-1]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: '__NSConcreteUUID' object does not support indexing
>>> type(foo)
<objective-c class __NSConcreteUUID at 0x7fff737e7800>
>>> for thing in dir(foo):
... print thing
# interesting
# snip
UUIDString
# snip
>>> print foo.UUIDString
<native-selector UUIDString of <__NSConcreteUUID 0x7f9a78df73b0> 19AE1973-8C5C-40D7-BBE4-073F6EA3B0D5>
# Insert A bunch of silliness before asking for help
# https://twitter.com/mikeymikey/status/626424612968988672
# @mikeymikey 1h1 hour ago
# @rmanly YOU WERE SO CLOSE!
# foo.UUIDString()
# When you see 'native-selector' it's string to tell you that's the function - just run it!
>>> foo.UUIDString()
u'19AE1973-8C5C-40D7-BBE4-073F6EA3B0D5'
# NOTE TO SELF # look for __call__ in dir(foo.UUIDString) etc.
# ≈≈≈≈≈★
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment