Majinboo
I would do the UID instance variable the other way around:
instead of storing the names,UID in the PinName object, I would store the PinName.UID in the names object.
Then, anytime you pick a names object you can see if its PinNameUID variable is 0, then you know nothing is pinned to it. If there is a value in there, then you can pick the PinName object directly by that UID (rather than having go searching for PinName objects pointing back to the names object). That should simplify your code a lot.
(unless, of course, you want to have more than one PinName object pinned to the names object at a time... but it doesn't look that way to me)