Cocoa Dev
Cocoa Dev

Reputation: 9551

NSTextField on my UI and need to access them by tag

I have 8 NSTextFields and I need to access them by UI to determine if the NSTextField has any data. If it's empty then I mark a bool as NO and check the next field. Eventually I'll highlight all the required fields and present it to the user.

Here's my pseudocode

-(BOOL)isFormValid
{
for(int i=0; i< 9; i++)
{
if <tag>.text != nil or <tag>.text != @"" then
return NO
}
return YES;
}

Upvotes: 1

Views: 121

Answers (2)

jscs
jscs

Reputation: 64022

Why don't you use an NSForm? As the name suggests, it's designed for text forms. You have one outlet to the form as a whole and can get each field in the form with cellAtIndex:

Screenshot of <code>NSForm</code> object in IB

Upvotes: 0

user529758
user529758

Reputation:

Probably this will help:

[superviewOfTextFields viewWithTag:tag];

Upvotes: 1

Related Questions