Mc.Lover
Mc.Lover

Reputation: 4994

equaling indexPathForRow with UItextField

i am trying to implement something that user can insert an number then program show me the row number but i little bit confusing , i would be grateful if you help me , here is my code :

for(int i = 0; i < myTextField.text; i++) {
[myScrollTable selectRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0 ] animated:YES scrollPosition:UITableViewScrollPositionTop];

the compiler shows me a Warning and app crashes what can i do to equal my UtextField with indexPathForRow ?

warning alert: comparison between pointer and integer

Upvotes: 0

Views: 259

Answers (1)

Jason Harwig
Jason Harwig

Reputation: 45551

You need to convert the textfield value to an int. That's what the compiler is warning you about.

for(int i = 0; i < [myTextField.text intValue]; i++) { ...

Not sure why you're using a loop if you only want to scroll to the row. Use scrollToRowAtIndexPath:atScrollPosition:animated: (Reference Doc)1

Upvotes: 1

Related Questions