Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Possible to find MIN of UITextFields with corresponding UILabel as the Result in Obj-c?

I'm wanting to do the following:


12 UITextFields (each will call an int that ranges between whole numbers 2 - 200)

12 UILabels that correspond to each UITextField ("Month 1" Label corresponds/belongs to "Month1" TextField and so on..)


and have the UITextField that contains the lowest number print in a Results UITextField the corresponding Month.


IF there is a tie on only the lowest ranking number of the 12 (i.e. Month 1 & Month 12 both equal 5 and 5 is the lowest number of the 12) the output has to be the Month closest to 1. (in this example it would be "Month 1")


Currently the following is not working (after declaring the ints "a" thru "l"):


min(a,b,c,d,e,f,g,h,i,j,k,l) = min(min(a,b),c), min(min(d,e),f), min(min(g,h),i), min(min(j,k),l);




Where am I going wrong? What am I missing here? Thanks.

Numbers '09-OTHER

Posted on Aug 5, 2011 11:15 PM

Reply
4 replies

Aug 6, 2011 9:33 PM in response to WSchoen

This is a little method I worked up:


test.h

-(int)findMin:(NSArray *)arrayOfIntegers;

-(void)callFindMin;


test.m

-(int)findMin:(NSArray *)arrayOfNSNumbers

{

int min = 0;

for (int i=0; i<[arrayOfNSNumbers count]; i++)

{

if (i==0)

min = [[arrayOfNSNumbers objectAtIndex:i] intValue];

if ([[arrayOfNSNumbers objectAtIndex:i] intValue] < min)

min =[[arrayOfNSNumbers objectAtIndex:i] intValue];

}

return min;

}


-(void)callFindMin

{

NSNumber *a = [[NSNumberalloc]initWithInt:200];

NSNumber *b = [[NSNumberalloc]initWithInt:100];

NSNumber *c = [[NSNumberalloc]initWithInt:10];


NSArray *array = [NSArrayarrayWithObjects:a,b,c, nil];

NSLog(@" min=%i", [selffindMin:array]);


[a release];

[b release];

[c release];

}


No guarantees but I did a little bit of testing and it seemed to work.

Possible to find MIN of UITextFields with corresponding UILabel as the Result in Obj-c?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.