0

I struct at a point in my application.I have an array object called time and a global int variable as index..so when I need to use both I need to type cast array object to integer value.How can I do this?Please help..

NSArray *time=[NSArray arrayWithObjects:@"1.08",@"1.12",@"1.14",@"1.18",@"1.20",@"1.24",@"1.25",@"1.29",@"1.30",@"1.34",@"1.45",@"1.50",@"1.51",@"1.55",@"1.56",@"2.00",@"2.01",@"2.06",@"2.07",@"2.11",@"2.12",@"2.16",@"2.17",@"2.21",nil];
index = 0;
[self performSelector:@selector(startAnimation) withObject:self afterDelay:[time objectAtIndex:index]];

This is my code,but it is giving error and telling to typecast

1 Answer 1

4

Try [[time objectAtIndex:index] floatValue]. The objects in array are strings and you can get the float value by calling [myStr floatValue]. You can also use doubleValue here.

Sign up to request clarification or add additional context in comments.

2 Comments

@taskinoor How do I get the maximum or minimum value in that case ? I won't be able to do [time.@"@max.keyPathToProperty"] is there a way to do that ?
@Farini, not sure what you are asking, and it does not look like a question related to this original question. You can ask a new question so that people can answer that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.