Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-16-2011, 10:27 AM   #1 (permalink)
Registered Member
 
Join Date: Oct 2011
Posts: 10
marcelo8576 is on a distinguished road
Default Countdown Timer problem.

I'm a beginner at Xcode 4 and my current goal is to make a countdown timer. I figured to make something like this: put a text field that can be read by the program when the round rect button is pressed. What I got so far:

*.m part:

-(void)countdown {
MainInt -= 1;
seconds.text = [NSString stringWithFormat:@"%i", MainInt];
}

-(IBAction)start:(id)sender {
MainInt = X;
timer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self selector:@selector(countdown)userInfo:nil repeats:YES];
}




*.h part:

{
IBOutlet UITextField *seconds;

NSTimer *timer;
int MainInt;
}
-(IBAction)start:(id)sender;
-(void)countdown;


---------------------------------
The part I need to change is in the *.m part, which decides the initial MainInt value. How can I type this value in the text box and then make the program read it and set MainInt as the value read?

Thank you,

Marcelo :)
marcelo8576 is offline   Reply With Quote
Old 10-16-2011, 12:52 PM   #2 (permalink)
Registered Member
 
Join Date: Oct 2011
Posts: 10
marcelo8576 is on a distinguished road
Default

No solution for such an easy problem? Ummmm...
marcelo8576 is offline   Reply With Quote
Old 10-16-2011, 01:06 PM   #3 (permalink)
Super Moderator
 
Join Date: Jan 2011
Posts: 434
Rhade is on a distinguished road
Default

I love it when new people come in here and then get pissy if their question isn't answered immediately. If the problem is so simple, then solve it yourself.

And bumping after ~2 hours on a Sunday? Please.
__________________
Do not quote questionable posts.
Do not post moderator requests in public. Report the post or send a PM.
<----- Use the red flag button to report posts.
Rhade is offline   Reply With Quote
Old 10-16-2011, 01:13 PM   #4 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

Lol... this almost makes me not want to answer his problem and tell him to go hire a developer...almost...

Create a UITextField in IB and create an IBOutlet to it. Create a button that says set time. Link this button to a method that reads the value out of the UITextField by retrieving its "text" NSString property and calling intValue on it. Then set your MainInt variable. Btw, follow the naming convention, lowerCaseThenUpperCase.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.

New app - See screenshots and details at www.globaclock.com.

If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
Domele is offline   Reply With Quote
Old 10-16-2011, 03:01 PM   #5 (permalink)
Registered Member
 
Join Date: Oct 2011
Posts: 10
marcelo8576 is on a distinguished road
Default

Quote:
Originally Posted by Domele View Post
Lol... this almost makes me not want to answer his problem and tell him to go hire a developer...almost...

Create a UITextField in IB and create an IBOutlet to it. Create a button that says set time. Link this button to a method that reads the value out of the UITextField by retrieving its "text" NSString property and calling intValue on it. Then set your MainInt variable. Btw, follow the naming convention, lowerCaseThenUpperCase.
Sorry if that was so difficult to you, thanks for the reply anyway.

Quote:
Originally Posted by Rhade View Post
I love it when new people come in here and then get pissy if their question isn't answered immediately. If the problem is so simple, then solve it yourself.

And bumping after ~2 hours on a Sunday? Please.
Just saying, if this is a forum made specially for iPhone SDK issues and nobody posts an answer after two hours for a second-counter, the only thing you can think is that this either difficult or this forum isn't that popular. Because it's a counter, I think searching another forum with more people willing to cooperate and actually help newbies is a better option.

Hope you learn how to deal with people,

Marcelo
marcelo8576 is offline   Reply With Quote
Old 10-16-2011, 03:09 PM   #6 (permalink)
Registered Member
 
Join Date: Oct 2011
Posts: 10
marcelo8576 is on a distinguished road
Default

Quote:
Originally Posted by Domele View Post
Lol... this almost makes me not want to answer his problem and tell him to go hire a developer...almost...

Create a UITextField in IB and create an IBOutlet to it. Create a button that says set time. Link this button to a method that reads the value out of the UITextField by retrieving its "text" NSString property and calling intValue on it. Then set your MainInt variable. Btw, follow the naming convention, lowerCaseThenUpperCase.
Ok, already created the UITextField in IB and it's outlet. I just don't get how to retrieve the text from the TextField.

Thanks!

Marcelo
marcelo8576 is offline   Reply With Quote
Old 10-16-2011, 03:41 PM   #7 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by marcelo8576 View Post
Sorry if that was so difficult to you, thanks for the reply anyway.



Just saying, if this is a forum made specially for iPhone SDK issues and nobody posts an answer after two hours for a second-counter, the only thing you can think is that this either difficult or this forum isn't that popular. Because it's a counter, I think searching another forum with more people willing to cooperate and actually help newbies is a better option.

Hope you learn how to deal with people,

Marcelo

Dude, the snotty attitude is not going to get you much help. You come off as a jerk. An impatient jerk at that.

There are plenty of helpful people here, but you are unlikely to get help by snarking and sniping.

I suggest you back off with the bad attitude and try again.

By the way, this forum has a rule against bumping your threads after less than 12 hours. Rhade is a moderator here. He warned you once. If you continue to bait him, I'm sure he'd be willing to show you the door to this forum.

Quote:
Hope you learn how to deal with people
That's really rich. You come in as a newbie, asking for help, and get snotty when nobody leaps to your aid after two hours on a Sunday? Then when you get called on your rude behavior, you say you hope a forum moderator learns how to deal with people? You need to get a clue, buddy.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.

Last edited by Duncan C; 10-16-2011 at 03:52 PM.
Duncan C is offline   Reply With Quote
Old 10-16-2011, 03:44 PM   #8 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by marcelo8576 View Post
Ok, already created the UITextField in IB and it's outlet. I just don't get how to retrieve the text from the TextField.

Thanks!

Marcelo
UITextFields have a property, text.

If you have a UITextField myTextField, you can get the contents like this:

Code:
NSString* theText = myTextField.text;
NSString has a method intValue that lets you get the integer value of a string.

The syntax for THAT looks like this:

Code:
int theValue = [theText intValue];
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 10-16-2011, 03:53 PM   #9 (permalink)
Registered Member
 
Join Date: Oct 2011
Posts: 10
marcelo8576 is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
UITextFields have a property, text.

If you have a UITextField myTextField, you can get the contents like this:

Code:
NSString* theText = myTextField.text;
NSString has a method intValue that lets you get the integer value of a string.

The syntax for THAT looks like this:

Code:
int theValue = [theText intValue];
Aww that's confusing >.< where should I insert the NSString* theText = myTextField.text? And the int theValue? .m or .h? I'm sooooo noob at this language, sorry :O
marcelo8576 is offline   Reply With Quote
Old 10-16-2011, 03:57 PM   #10 (permalink)
Super Moderator
 
Join Date: Jan 2011
Posts: 434
Rhade is on a distinguished road
Default

Quote:
Originally Posted by marcelo8576 View Post
Just saying, if this is a forum made specially for iPhone SDK issues and nobody posts an answer after two hours for a second-counter, the only thing you can think is that this either difficult or this forum isn't that popular. Because it's a counter, I think searching another forum with more people willing to cooperate and actually help newbies is a better option.

Hope you learn how to deal with people,

Marcelo
So let me get this straight... you are brand new here. You've never done anything for anyone on this forum. You just show up and ask a question. On a Sunday. When people might be, you know, enjoying their weekend instead of wasting time on a forum, any forum. You are not offering any money; that's why you posted in the forums instead of hiring a consultant. So you think you can just demand that total strangers should help you immediately on the weekend for free.

And I'm the one who needs to learn how to deal with people? Pot. Kettle. Black.

You want to know how I deal with people like you? Well unless your attitude improves considerably, and quickly at that, you're going to find out. That's a promise.
__________________
Do not quote questionable posts.
Do not post moderator requests in public. Report the post or send a PM.
<----- Use the red flag button to report posts.
Rhade is offline   Reply With Quote
Old 10-16-2011, 03:59 PM   #11 (permalink)
Registered Member
 
Join Date: Oct 2011
Posts: 10
marcelo8576 is on a distinguished road
Default

Quote:
Originally Posted by Rhade View Post
So let me get this straight... you are brand new here. You've never done anything for anyone on this forum. You just show up and ask a question. On a Sunday. When people might be, you know, enjoying their weekend instead of wasting time on a forum, any forum. You are not offering any money; that's why you posted in the forums instead of hiring a consultant. So you think you can just demand that total strangers should help you immediately on the weekend for free.

And I'm the one who needs to learn how to deal with people? Pot. Kettle. Black.

You want to know how I deal with people like you? Well unless your attitude improves considerably, and quickly at that, you're going to find out. That's a promise.
Just...
marcelo8576 is offline   Reply With Quote
Old 10-16-2011, 04:00 PM   #12 (permalink)
Super Moderator
 
Join Date: Jan 2011
Posts: 434
Rhade is on a distinguished road
Default

Quote:
Originally Posted by marcelo8576 View Post
I'm sooooo noob at this language, sorry :O
You therefore lack the proper qualifications necessary in order to make an assessment regarding how challenging (or not) a particular issue is. You should keep this in mind for future requests.
__________________
Do not quote questionable posts.
Do not post moderator requests in public. Report the post or send a PM.
<----- Use the red flag button to report posts.
Rhade is offline   Reply With Quote
Old 10-16-2011, 04:10 PM   #13 (permalink)
Registered Member
 
Join Date: Oct 2011
Posts: 10
marcelo8576 is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
UITextFields have a property, text.

If you have a UITextField myTextField, you can get the contents like this:

Code:
NSString* theText = myTextField.text;
NSString has a method intValue that lets you get the integer value of a string.

The syntax for THAT looks like this:

Code:
int theValue = [theText intValue];
Wait wait wait, should I do like:
Code:
NSString* theText = myTextField.text;
    theValue = [theText intValue];
Insert that in the header and when the button is clicked, it'll do
Code:
myTextField.text = [NSString stringWithFormat:@"%i", theValue];
?
marcelo8576 is offline   Reply With Quote
Old 10-16-2011, 04:22 PM   #14 (permalink)
Registered Member
 
Join Date: Oct 2011
Posts: 10
marcelo8576 is on a distinguished road
Default

Okay, I got it, thanks to Duncan Sorry for being hasty at first, I was upset...

One more thing: how can I make the program play sounds?
I was hoping to make an "if" statement that plays a sound when theValue gets to 0... It can be done, right?

Last edited by marcelo8576; 10-16-2011 at 04:31 PM.
marcelo8576 is offline   Reply With Quote
Old 10-16-2011, 06:15 PM   #15 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by marcelo8576 View Post
Okay, I got it, thanks to Duncan Sorry for being hasty at first, I was upset...

One more thing: how can I make the program play sounds?
I was hoping to make an "if" statement that plays a sound when theValue gets to 0... It can be done, right?
Of course. Take a look at the the AVAudioPlayer class. Since you're very new at this, you might want to look at sample applications that use it.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 10-16-2011, 06:29 PM   #16 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 100
XcodeMagic is on a distinguished road
Default

Just ignore him.. If hes a beginner he is bound to go NO WHERE with his attitude when it comes to help.

The way I learnt how to do exactly what you are asking is youtube. there are hundred of videos about coding, and easy coding. Before you come on a forum and ask for help, go to youtube, then google the problem to find posts that relate to your problem

and

with this problem, there are countless forum posts all over google and Im sure videos too,

and after if you cant find videos, or forum discussion on google about it, OR YOU just dont understand anything the videos or forum are showing you step by step or its not working for you..

THEN you come on a forum and post a question. Good luck once again trust me there is countless examples of this on the web.
XcodeMagic is offline   Reply With Quote
Old 10-16-2011, 06:42 PM   #17 (permalink)
Registered Member
 
Join Date: Oct 2011
Posts: 10
marcelo8576 is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
Of course. Take a look at the the AVAudioPlayer class. Since you're very new at this, you might want to look at sample applications that use it.
Okay! Thanks Duncan

bye
marcelo8576 is offline   Reply With Quote
Old 10-16-2011, 06:46 PM   #18 (permalink)
Registered Member
 
Join Date: Oct 2011
Posts: 10
marcelo8576 is on a distinguished road
Default

Quote:
Originally Posted by XcodeMagic View Post
Just ignore him.. If hes a beginner he is bound to go NO WHERE with his attitude when it comes to help.

The way I learnt how to do exactly what you are asking is youtube. there are hundred of videos about coding, and easy coding. Before you come on a forum and ask for help, go to youtube, then google the problem to find posts that relate to your problem

and

with this problem, there are countless forum posts all over google and Im sure videos too,

and after if you cant find videos, or forum discussion on google about it, OR YOU just dont understand anything the videos or forum are showing you step by step or its not working for you..

THEN you come on a forum and post a question. Good luck once again trust me there is countless examples of this on the web.
Yeah, I was just looking for tutorials on YouTube but the code was old or something, I think it was Xcode 3 at the time... I just got my brand-new MacBook Air, the last one of the S.J. generation and since I'm not using my PC so often, I figured I stop dealing with C++ and get to know Xcode...

Thank you all,

Marcelo
marcelo8576 is offline   Reply With Quote
Old 10-16-2011, 06:57 PM   #19 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

Xcode versions don't matter, the code will still be the same. Only time code changes is when Apple decides to toss out some methods and replace them with new ones. Even then, the old methods will still work, it's just not advised to use them.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.

New app - See screenshots and details at www.globaclock.com.

If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
Domele is offline   Reply With Quote
Old 10-16-2011, 07:20 PM   #20 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 100
XcodeMagic is on a distinguished road
Default

Quote:
Originally Posted by Domele View Post
Xcode versions don't matter, the code will still be the same. Only time code changes is when Apple decides to toss out some methods and replace them with new ones. Even then, the old methods will still work, it's just not advised to use them.
While on the topic domele, I,m building my app game in xcode 4.0.2, will that code be complatible with ios 5? I want to make it as wide spread IOS compatible as I can and IOS is a must now including IOS 4 and MAYBE IOS3. is xcode 4.0.2 good for that? I just have a simple 2 d game you move stuff and they do things.
XcodeMagic is offline   Reply With Quote
Old 10-16-2011, 07:21 PM   #21 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 100
XcodeMagic is on a distinguished road
Default

Lol as simple as it sounds I got 23,000 lines of code.. thats just in my .m controller view. It turned from a simple idea to quite the complex thing. it will be out soon tho 7 months of work!
XcodeMagic is offline   Reply With Quote
Old 10-16-2011, 07:24 PM   #22 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

I can't accurately judge since I don't know what your controller does but if you have 23,000 lines of code in it, you might be bundling too many things in one class.

Also, you can compile for iOS 3-iOS5 on Xcode 4. Just make sure to not use any methods that appeared after iOS 3. If you do need to use a method that is not compatible with an iOS version you are building for, either make sure it's an optional feature and check whether the method is available in the user's iOS version or have a backup solution.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.

New app - See screenshots and details at www.globaclock.com.

If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.

Last edited by Domele; 10-16-2011 at 07:27 PM.
Domele is offline   Reply With Quote
Reply

Bookmarks

Tags
countdown, timer

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 405
15 members and 390 guests
13dario13, 7twenty7, buggen, eski, EvilElf, glenn_sayers, j.b.rajesh@gmail.com, LunarMoon, morterbaher, n00b, QuantumDoja, sacha1996, Sami Gh, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,673
Threads: 94,122
Posts: 402,906
Top Poster: BrianSlick (7,990)
Welcome to our newest member, morterbaher
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:26 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0