Skip to content

Instantly share code, notes, and snippets.

@polarity
Created August 30, 2012 13:23
Show Gist options
  • Save polarity/3528446 to your computer and use it in GitHub Desktop.
Save polarity/3528446 to your computer and use it in GitHub Desktop.
UITextField: Observe text input
// Typische UIViewController Methode
// Wird ausgeführt wenn der View im Speicher
// vollständig geladen wurde.
- (void)viewDidLoad
{
[super viewDidLoad];
// Wir sagen dem handle das er das mit dem Großbuchstaben bei
// neuen Wörtern einfach schon mal lassen soll.
self.handle.autocapitalizationType = UITextAutocapitalizationTypeNone;
// Default Notification Center holen
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
// Und Bei jedem Tipper Methode "type" aufrufen
// Daten müssen wir nicht übergeben, die Methode
// befindet sich eh hier im selben Controller und wir
// können direkt auf "handle" zugreifen
[nc
addObserver: self // Mit diesem ViewController überwachen
selector:@selector(type) // und bei Event "type" aufrufen
name:UITextFieldTextDidChangeNotification // Zu überwachender System Kanal
object:nil // Alle Objekte annehmen
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment