Objective C: selector in NSDictionary speichern und wieder auslesen

Written by

in

SEL ist einfach ein Pointer, der sich als NSValue speichern lässt:

NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: 
[NSValue valueWithPointer:@selector(foo)], @"foo",
nil];

Zum Auslesen des Selectors hilft folgender Code:

SEL aSel = [[dict objectForKey:@"foo"] pointerValue];

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *