Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
For someone seeking our help, you sure are quick to dismiss it. Again, everyone in this thread has been trying to help you. A little cooperation on your part would be appreciated.

Help us help you. If we have questions, it's because we don't quite understand what you are seeking help on.
 
The "quiz questions" are necessary because we don't know what it is you know or think you know. We can't read your mind. This is how information is exchanged and we can come to the appropriate level or explanation to be able to help you. It can also help you find the answer yourself by talking through it.


talking through it ?? thats funny, as soon as someone mentions "what's a pointer"..everyone shoots to kill here, and they tell you to step out or go deep yourself in books. The last thing you'll get is a simple answer, which 1 out 20 developers give you without asking you "Have you even read the objective-C manual?? cause if not you should leave the Real Coding and go study now"

For someone seeking our help, you sure are quick to dismiss it. Again, everyone in this thread has been trying to help you. A little cooperation on your part would be appreciated.

Help us help you. If we have questions, it's because we don't quite understand what you are seeking help on.


Knight, just go to page 2 and look at the problem. It's very clear what I'm looking for and many developers have try to solve it. dejo describes it step by step. If you don't understand ask me, because many others understand it.

(I think 2/3 pages in this thread are not related to the code itself, instead everybody is giving his point of view about why or why not Pro developers should help new ones.)
 
Last edited by a moderator:
everybody is giving his point of view about why or why not Pro developers should help new ones.)

No one has given a point of view about that. You quite misunderstand what everyone is saying.

As for your code, you still have not really given us a clear indication of at what stage you are now and what isn't working. Now we know you want to do a sort of count down timer. I'm guessing you're trying to make a cooking timer kind of app since you said you were a pastry chef and that was what your first app was based on. Is this correct ? (<-- not a quiz question).

Now, what is not working ? Is the timer getting created ? Is it calling the method identified by the target and selector attributes when the interval you specified ends ? Is it repeating or not repeating (depending on how you set the repeat parameter on it) ?

When a timer repeats, it will simply call back the selector in the target specified.

Does your button that "cancels" it call your cancel method ? What have you done to check this ?

With the little code you posted, and since you haven't provided screenshots of your associations in Interface Builder, these are all pending questions we have that are preventing us from helping you thoroughly. This is not a quiz, these are things we need to know to help you.

So, self refers to my controller.. interesting.

No, self refers to the instance of the object that is executing the currently running code. It is highly context dependant.

Inside a method of your view controller, yes, self refers to your view controller. Inside a method in your view object, self refers to the view object. Inside the NSTimer object, self refers to the NSTimer.
 
My sources.. well, my main sources is the Apple documentation (all of it), then theres books and all the same stuff than most developers learn from. And.. no I haven't read all of the books, nor watch every video but I will.

Again with the lack of specificity. :rolleyes:

Being specific is a huge part of learning how to program, because computers only do what you tell them to do. (As you should have learned just by living through this thread).

It's not essential to read every page of every book, but certain books are good at explaining particular concepts. Others, less so.

Telling us specifically which resources got you in this mess, can help us point you at the relevant portions of the resources you already have at your disposal. It also can help us the next newbie who doesn't know a method from an object instance, by pointing them to different resources to avoid your mistakes.

For example, if we know you have access to Kochan's book we could be more specific and say: "Go back and re-read Chapter 3 on "Classes, Objects and Methods"" instead of a more generic "step back and learn the fundamentals".

No, self refers to the instance of the object that is executing the currently running code.

Which Nekbeth might actually know if they took the time to learn something about objects, for example from said Chapter 3 in Kochan. For me, it remains the best description of objects I have read.

B
 
If I want to open 10 threads on the subject in 10 different forums, well.. **** it.. that is how I like it.

If you want to take a dump in the pool because "that's the way you like it" that's fine. Don't expect anyone else to like it.

(I think 2/3 pages in this thread are not related to the code itself, instead everybody is giving his point of view about why or why not Pro developers should help new ones.)

Obviously you attract that, for some reason.
 
talking through it ?? thats funny, as soon as someone mentions "what's a pointer"

FWIW, what I mean by talking through it is you explaining it to someone else. Not just "why isn't what I want to do working?" but "I think, given these conditions, and this code, I should get this result for these reasons." This way you have to document your assumptions, code, expectations and reasoning.

Often times, just going through that process will lead you to the answer yourself or with a gentle nudge from someone else.

THAT is where links I posted earlier are headed and you refuse obstinately to go.

If you want to take a dump in the pool because "that's the way you like it" that's fine. Don't expect anyone else to like it.

I LOLed.

B
 
I have to say this thread has me captivated. First time ever..... code talk went from learning code to pooping in a pool within 3 pages.
 
I have to say this thread has me captivated. First time ever..... code talk went from learning code to pooping in a pool within 3 pages.

By this point I would have expected Nekbeth to have called us "Nazis" instead of "Pros" in order to satisfy Godwin's Law.

Which of course I have now done. :p ;)

B
 
No, self refers to the instance of the object that is executing the currently running code. It is highly context dependant.

Inside a method of your view controller, yes, self refers to your view controller. Inside a method in your view object, self refers to the view object. Inside the NSTimer object, self refers to the NSTimer.

Yes, that's what I though.. I was asked the meaning of "target", so I gave an example that target:self in NSTimer refer to the timer object (one of my quiz questions), but I can't remember his name.. said that "self" refer to the controller even inside the NSTimer. That's why I said.. interesting, I mean.. all of you should know what your talking about a lot more than me. (specially Master balamw)

About the timer and how it's going... well, I really don't have time to continue to make it work, so I have postpone it for a later update. I just need to learn more about it to fix it. But hey, If you feel like giving the answer, go ahead.

The only thing that I'm missing is to restart the Timer (or use another one). Invalidating my Timer only pauses it, even = nil or releasing it, my Timer just continues where it left.

I have found a tutorial where you can start, stop and reset a timer, I could use that, but I want a datePicker to select time and the tutorial doesn't show that. Here is the link: http://www.youtube.com/watch?v=5jmTQi98vec&feature=related

Please, let me know if you need more code of the timer. I think I have share all of it.

balamw;12474773]By this point I would have expected Nekbeth to have called us "Nazis" instead of "Pros" in order to satisfy Godwin's Law.
B

that is the dumbest thing I've read in a while :p
 
Last edited by a moderator:
I have found a tutorial where you can start, stop and reset a timer, I could use that, but I want a datePicker to select time and the tutorial doesn't show that. Here is the link: http://www.youtube.com/watch?v=5jmTQi98vec&feature=related

Divide and conquer.

Where he makes the counter count backwards from 600 by hardcoding the initial value in the label, make that a variable that is tied to the datePicker of your choice.

If you want to do it in baby steps, first use two labels one for the input and one for the display to input the starting time and then replace the input one with your datePicker.

B
 
The only thing that I'm missing is to restart the Timer (or use another one). Invalidating my Timer only pauses it, even = nil or releasing it, my Timer just continues where it left.

What makes you think that ? Once you invalidate a timer, it's done and gone. Look, I implemented a timer that updates on screen with minutes:seconds and it gets reset properly when I invalidate it (take a peek at the screenshot).

A screenshot like this goes a long way. Console output with NSLog to know what gets called and when is even better.

If you posted up the full code of your viewController, we might even be able to point you in the right direction. The more you are specific, the better we can help.

I'm thinking you don't quite grasp what an NSTimer object is. It's not an actual timer as in a chicken timer. It's just an object that's inserted into the run loop, waits for a specificied interval and then calls a method (depending either the NSInvocation or the target/selector you used when creating it). If you set its repeat to YES, it will call this method over and over again at the specified interval.

This specified method (in my screenshot that would be updateLabel) has to do some processing to display minutes:seconds on a label.
 

Attachments

  • Screen shot 2011-04-27 at 9.06.35 PM.png
    Screen shot 2011-04-27 at 9.06.35 PM.png
    140.8 KB · Views: 105
If you posted up the full code of your viewController, we might even be able to point you in the right direction. The more you are specific, the better we can help.

Yup. Again, divide and conquer. If you don't want to share your entire code because it does something else, you don't want to reveal, pull out what is needed to demonstrate the problem into a test app to figure it out.

If you post nominally compilable code you are more likely to get to your desired answers faster.

B
 
I going to do that balamw, I'll show you what I got so far in little while.

Knight , I don't know how you do it. Check my photo log, mine keeps on running.
 

Attachments

  • 1.jpg
    1.jpg
    105.2 KB · Views: 104
How do you count your elapsed ? Again, NSTimer is simply an object inserted into the run loop. It has no conception of elapsed time beyond its own internal interval.

What methods are being called and by what ? What is the code to those methods ?

You have posted bit and pieces all over the thread, why not just post a readable, compilable example of everything you have that can help us reproduce or see your actual problem ?
 
I'm only posting my timer code balamw, you don't want to see the rest and even if you do, I wouldn't show it here. The only problem is the timer the rest works fine. You can check out my App tomorrow morning (Availability Date is 28 of April). Look for "Pastry Chef app"

How do you count your elapsed ? Again, NSTimer is simply an object inserted into the run loop. It has no conception of elapsed time beyond its own internal interval.

What methods are being called and by what ? What is the code to those methods ?

You have posted bit and pieces all over the thread, why not just post a readable, compilable example of everything you have that can help us reproduce or see your actual problem ?


Alright Knight, I'll show it all. Just please, if you see a problem that it's obvious to you, don't play or make trick questions, you can just explain it and I'll work it out.
 
Last edited by a moderator:
I'm only posting my timer code balamw, you don't want to see the rest and even if you do, I wouldn't show it here. The only problem is the timer the rest works fine. You can check out my App tomorrow morning (Availability Date is 28 of April). Look for "Pastry Chef app"

Then, as I suggested above you need to pull all of that timer related code out into a "toy"/"test" app that you can post the entire code of to help us help you. As KnightWRX says we have to be able to reproduce what you are seeing to see the problem(s). This is part of the work you need to do to get help.

I don't think you are in a position to judge where it is broken, being that you don't care to understand fundamentals.

B
 
.h

Code:
#import <UIKit/UIKit.h>

@interface ATimerViewController : UIViewController {
    
    IBOutlet UIDatePicker *timePicker;
    
    IBOutlet UILabel *label; 
    IBOutlet UILabel *label2; 
    IBOutlet UILabel *label3;
    
    IBOutlet UIView *view1;
    IBOutlet UIView *view2;
    
    NSTimer *myTimer;
    NSTimer *newTimer;
    
}

@property (nonatomic, retain) IBOutlet UIDatePicker *timePicker;
@property (nonatomic, retain) IBOutlet  UILabel *label;
@property (nonatomic, retain) IBOutlet  UILabel *label2;
@property (nonatomic, retain) IBOutlet  UILabel *label3;
@property (nonatomic, retain) IBOutlet UIView *view1;
@property (nonatomic, retain) IBOutlet UIView *view2;




// MINUTES (2)
- (IBAction) echoMinute: (id) sender;
- (void) echoIt2: (NSTimer *) timer;


// SECONDS (3)
- (IBAction) echoTime: (id) sender;
- (void) echoIt: (NSTimer *) timer;                 


//NEW TIMER
- (IBAction) newActionTimer: (id)sender;
- (void) echoNewTimer: (NSTimer *) timer2;


// NEW PAGE
- (IBAction) nextPage: (id) sender;




@end




.m

Code:
#import "ATimerViewController.h"

@implementation ATimerViewController


@synthesize timePicker;
@synthesize label;
@synthesize label2;
@synthesize label3;
@synthesize view1;
@synthesize view2;




NSInteger seconds = 0;
NSInteger minutes = 0;



// MINUTES  (2)                     ----------------MINUTES-----------------

- (IBAction) echoMinute:(id)sender

{
    
    NSDate * time = timePicker.date;
    NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
    [dateFormatter setDateFormat:@"HH:MM:SS"];
    NSLog(@"date:%@", [dateFormatter stringFromDate:time]);
    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    
    NSDateComponents *comps = [gregorian components:(NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:time];
    
    NSInteger hour = [comps hour];
    NSInteger minute = [comps minute];
    NSLog(@"Hour:%i", hour);
    NSLog(@"minute:%i", minute);
    NSInteger secs =hour * 60 * 60 + minute * 60;
    NSInteger mins = secs / 60;
    
    
    
    NSNumber *elapsedMinutes = [NSNumber numberWithInt:mins];
    NSDictionary *myMinute = [NSDictionary dictionaryWithObject:elapsedMinutes forKey:@"TotalMinutes"];
    
    [NSTimer scheduledTimerWithTimeInterval:60 target:self selector:@selector(echoIt2:) userInfo:myMinute repeats:YES];
    
    
    
    
    label.text = [NSString stringWithFormat:@"Hours: %i, Min: %i", hour, minute];       // TIME CHOSEN  (1st Label)
    
    
}



- (void) echoIt2:(NSTimer *)timer      //  MINUTES METHOD  

{
    
    NSNumber *num = (NSNumber *) [[timer userInfo] valueForKey:@"TotalMinutes"];   //elapsed
    minutes++;
    
    NSInteger min = [num integerValue] - minutes;                                 //remaining
    NSLog(@"elapsed: %i, remaining: %i", minutes, min);
    
    if (min <=0) 
    {
        [timer invalidate];
    }
    
    label2.text = [NSString stringWithFormat:@"Minutes remaining: %i", min];              // (2nd Label)
    
}





// SECONDS  (3rd Label)                        ----------------SECONDS-----------------




- (IBAction) echoTime:(id)sender 

{   
    
    
    NSDate * time = timePicker.date;
    NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
    [dateFormatter setDateFormat:@"HH:MM:SS"];
    NSLog(@"date:%@", [dateFormatter stringFromDate:time]);
    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSDateComponents *comps = [gregorian components:(NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:time];
    
    NSInteger hour = [comps hour];
    NSInteger minute = [comps minute];
    NSLog(@"Hour:%i", hour);
    NSLog(@"minute:%i", minute);
    NSInteger secs =hour * 60 * 60 + minute * 60;
        
    NSNumber *elapsedSeconds = [NSNumber numberWithInt:secs];
    NSDictionary *myDict = [NSDictionary dictionaryWithObject:elapsedSeconds forKey:@"TotalSeconds"];
    
    
    myTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(echoIt:) userInfo:myDict repeats:YES];

}




- (void) echoIt:(NSTimer *)timer      //  SECONDS METHOD  (3)

{
    
    NSNumber *num = (NSNumber *) [[timer userInfo] valueForKey:@"TotalSeconds"];   //elapsed
    seconds++;

    NSInteger secs = [num integerValue] - seconds;                                 //remaining
    NSLog(@"elapsed: %i, remaining: %i", seconds, secs);
        
    if (secs <= 0)
    {
        [timer invalidate];
    timer = nil;
        
    }
     
    label3.text = [NSString stringWithFormat:@"Seconds remaining: %i", secs];         // (3rd Label)
        
}









//NEW TIMER                            ---------------- NEW TIMER -----------------


- (IBAction) newActionTimer: (id)sender
{
    NSDate * time = timePicker.date;
    NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
    [dateFormatter setDateFormat:@"HH:MM:SS"];
    NSLog(@"date:%@", [dateFormatter stringFromDate:time]);
    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    
    NSDateComponents *comps = [gregorian components:(NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:time];
    
    NSInteger hour = [comps hour];
    NSInteger minute = [comps minute];
    NSLog(@"Hour:%i", hour);
    NSLog(@"minute:%i", minute);
    NSInteger secs =hour * 60 * 60 + minute * 60;
    NSInteger mins = secs / 60;
    
    
    
    NSNumber *elapsedMinutes = [NSNumber numberWithInt:mins];
    NSDictionary *myMinute = [NSDictionary dictionaryWithObject:elapsedMinutes forKey:@"TotalMinutes"];
    
    newTimer = [NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(echoNewTimer:) userInfo:myMinute repeats:NO];


}



- (void) echoNewTimer: (NSTimer *)timer2

{
    
   [myTimer invalidate];
    myTimer = nil;
    
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Invalidate" 
                                                   delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    [alert release];
    
    [view1 setHidden:NO];
    [view2 setHidden:YES];
    
    
    //  is my newTimer On right now ?? 
}







//NEXT PAGE                      ---------------- NEXT PAGE -----------------


- (void) nextPage:(id)sender         

{
    [view1 setHidden:YES];
    [view2 setHidden:NO];
    
    
}

- (void) dealloc {
    
    [view1 release];
    [view2 release];
    [timePicker release];
    [super dealloc];
}


@end

Divide and conquer.

Where he makes the counter count backwards from 600 by hardcoding the initial value in the label, make that a variable that is tied to the datePicker of your choice.

If you want to do it in baby steps, first use two labels one for the input and one for the display to input the starting time and then replace the input one with your datePicker.

B

Ok, This is another code from the one I posted. Nothing to do with the other.

balamw. I have set two more labels like you said to be variables of the original label (where he sets the seconds) the both do the same. Now.. because they are used both to display and to input.. I have no idea how to make one of the variables that I made tied to the datePicker. (I get warnings that say their not compatible classes).

Here is the .m :

Code:
@synthesize datePicker;
@synthesize label;
@synthesize input;
@synthesize display;




- (IBAction)start: (id)sender

{
    
    
    myTicker = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(showActivity) userInfo:nil repeats:YES];    
}


- (IBAction)stop

{
    [myTicker invalidate];
}



- (IBAction)reset

{
    label.text = @"0";
    
    
    display.text = label.text;
    
    input.text = label.text;
    
    
    

    
}



- (void)showActivity

{
    int currenTime = [label.text intValue];
    int newTime = currenTime + 1;
    label.text = [NSString stringWithFormat:@"%d", newTime];
    
    display.text = label.text;
    
    input.text = label.text;
    
    
}
 

Attachments

  • Screen shot 2011-04-27 at 21.05.21.jpg
    Screen shot 2011-04-27 at 21.05.21.jpg
    43.1 KB · Views: 87
Last edited by a moderator:
thats funny, as soon as someone mentions "what's a pointer"..everyone shoots to kill here, and they tell you to step out or go deep yourself in books. The last thing you'll get is a simple answer, which 1 out 20 developers give you without asking you "Have you even read the objective-C manual?? cause if not you should leave the Real Coding and go study now

Fine. I'll give you a simple answer to "What is a pointer?".

It is a memory address. Nothing more and nothing less. The reason people don't give you the simple answer is because it will mean nothing to you and you won't understand the answer until you have read the articles and documents that people have been trying to get you to read.

Frankly having read this thread I think your behaviour is disgusting. People have been falling over themselves here trying to help you and you are just dismissing every single piece of help that is being offered to you.
 
Here we go with same old stuff..

And what makes you thing a simple answer doesn't mean anything to me? I get a lot of simple "direct" answers that have help me in the Apple Forum but If your so disgusted and sensitive, feel free to leave the thread, some people do want to help here.

This is almost like a Chess game, if I say that I have read Stephen G. Kochan's book, the beginning iPhone SDK programming with objective-c, Pro core data for OS, beginning iPHone development, the developers cookbook, Masters of the void and so on, as well as watch many iTunes U and WWDC videos... you know what many here are will say ?? how about " well then you should read them all over again or any x, y thing..

the point is.. you can't never fulfill peoples expectations and that applies to anything, not just programming. So, follow your way I say (theres no limitations there). My state of newbie or dummy if you want to call it, is temporary, just like any Pro was but you already get an idea of who's willing to help you and who just wants to play with you.
 
Look, your attitude really needs some adjustment Nekbeth. I have not asked a single trick question. My questions have all been about trying to understand what it is you're trying to do and what problems you are facing. You have been less than clear this whole time.

I think part of that problem is that you're thinking "I'm a newbie, these guys are pros, I'll probably get help but end up being laughed at". Seriously, if I want to laugh at people, I'll just head over to the news discussion. Those guys are a riot. And I'm not a pro at all. Sure I've been doing this for 15 some odd years in one form or another, but never as a job, only as a hobby.

The programming forum is full of newbies. I was a newbie once too. We all start somewhere and it's no laughing matter. I wouldn't spend all this time trying to figure out what it is you're doing wrong if it was only to laugh at you in the end.

Relax and try to realise we want to help you, otherwise we wouldn't be posting here. Now listen to us. We need your help too. As Pros, there are things we know that you might not, and you need to be clear and specific about your problem and what you're not understanding.

Now I'll try to take a look at the code you posted (I just got up and I need to get to work) and see if I can dig out something if someone doesn't do it faster than me.
 
Hats off to you all.

I must say, I have never seen a more patient group of mentors in my life.
Hats off to ya. You are all great. I've learned volumes reading your posts.

And thank you.
 
Nekbeth, I'm looking at the code and I'm thinking you still don't quite understand what NSTimer is and does. You keep track of "Elapsed" using 2 implementation scope global variables :

Code:
NSInteger seconds = 0;
NSInteger minutes = 0;

However, grepping for these variables, you never reset them back to 0 aside from their initial initialization :

Code:
$ grep -e minutes -e seconds ATimerViewController.m
NSInteger seconds = 0;
NSInteger minutes = 0;
    minutes++;
    NSInteger min = [num integerValue] - minutes;                                 
    NSLog(@"elapsed: %i, remaining: %i", minutes, min);
    seconds++;
    NSInteger secs = [num integerValue] - seconds;                                 
    NSLog(@"elapsed: %i, remaining: %i", seconds, secs);

Your minutes and seconds are thus never reset, so your "timer" is never reset (this is completely a seperate issue from NSTimer, hence why I say you probably don't understand the scope of NSTimer. It has no knowledge of these variables and thus doesn't reset them when you invalidate myTimer or newTimer).

Also, could you please post a screenshot of your Interface Builder associations ? (under File's Owner, the tab in Inspector with all the Outlets and Actions), because I can't quite figure out what buttons are tied to what actions.

You also still have 2 timers. Why do you believe you need both ? Have you tried simplifying the code to using only 1 ?

None of these are trick questions, It's me trying to understand what you think this code should do vs what it's actually doing. Now, if you don't answer my questions, I can't really help you here short of writing the code for you, which does not help you learn (I have a good idea how to make the code I wrote last night do what you want to do very quickly, but I doubt you can afford me as a consultant at my exorbitant rates!).
 
Last edited:
Thanks Knight, you are one of those who does helps no matter what, so I appreciate your patience, like Jethrotoe said. So, please don't take everything I typed and generalize it, because it's not for everyone. You personally look into the problem, ask questions about what's going on.. that is good !!, some other don't have your patience and throw in the typical sentence " Go learn fundamentals and come back" as soon as they see a basic mistake. So Patience I think is the right word to describe what's been going on here. It is actually a virtue and a basic one for a teacher to have.

Back to the code, here is a photo of my connections (ignore canceBigtimer). What you say is true I don't know how NSTimer works entirely , just some parts, I realize that and it is one of the reason I postpone my timer for a future update (need to study it).

You mention my two global variables, It makes sense that the timer does not stop because the variables are outside the method that creates the timer. is that whats going on?

I have two timers, because, like I said.. I don't have full knowledge of timers. I know now that 1 timer is enough, even if I use two timers and start them at the same time, the log only shows 1 loop and the countdown in separate labels show e.g. 59 in one and 58 in another and so on.

I got confuse because some other forums told me that I should make 2 timers.

It's ok, I never ask for code, I leave that to the person. You have pointed out a big mistake on my part already and that is more than I can ask. This code is actually from a follow up tutorial in one of my books to learn NSTimer, the name of the book is "iPhone SDK Programming, A Beginner's Guide ", after the book explains everything and the code is working, it doesn't tell you how to stop it, reset it or add minutes to it, and that is why I wanted to complete what was left from this book.
 

Attachments

  • Screen shot 2011-04-28 at 08.43.59.jpg
    Screen shot 2011-04-28 at 08.43.59.jpg
    82.9 KB · Views: 89
Your minutes and seconds are thus never reset, so your "timer" is never reset (this is completely a seperate issue from NSTimer, hence why I say you probably don't understand the scope of NSTimer. It has no knowledge of these variables and thus doesn't reset them when you invalidate myTimer or newTimer).

That has been pointed out. The OP is stuck thinking the timer is broken, when it works exactly as it should. I think the OP thinks that those variables are part of the timer. He also first thought "self" was the timer. I asked if/where he was resetting the seconds, and if he wanted a reset function or not. For all we know, he wants a start stop timer that doesn't reset. That would be a normal implementation.

Also, could you please post a screenshot of your Interface Builder associations ? (under File's Owner, the tab in Inspector with all the Outlets and Actions), because I can't quite figure out what buttons are tied to what actions.
That would be very helpful. Also, explain how you want the program to act as the user uses it.
You also still have 2 timers. Why do you believe you need both ? Have you tried simplifying the code to using only 1 ?
He was told elsewhere that he could not reuse a timer. I think he is still stuck on the concept (not necessarily the definition) of a pointer, and of the life-cycle of an object. I'm not sure he grasps that in the posted samples, the NSTimer was not being reused.
None of these are trick questions, It's me trying to understand what you think this code should do vs what it's actually doing. Now, if you don't answer my questions, I can't really help you here short of writing the code for you, which does not help you learn (I have a good idea how to make the code I wrote last night do what you want to do very quickly, but I doubt you can afford me as a consultant at my exorbitant rates!).


I have some code to post to help the OP. But for not, I'm about to get a parking ticket, so I have to leave. But I will post it today.
 
wlh99, let me tell you precisely what I want to achieve, so there is no more confusion.

Two views;

View 1 is the ticker and a button underneath (button start.

View 2 is display (label) with the timer running and a button underneath (button Cancel)

Button Cancel will have two maybe three funtions ( stop the timer, reset it or just reset it at once and call View1 so the user can reuse the timer over again. That's it, I want to add that function to my App for 1.1 or it could be 1.4 if don't get to study now hahaa.

I'll take care of the alarms, sounds and those details if it reaches to zero, that I know already.

By the way, what's with 3rd person reference? the OP? you can call me Nekbeth or Chrystian, it's a lot more polite. Maybe you guys have a way to refer to someone , I don't know.
 
Last edited by a moderator:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.