• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTimer and call-by-reference
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTimer and call-by-reference


  • Subject: Re: NSTimer and call-by-reference
  • From: Colin Jackson <email@hidden>
  • Date: Tue, 18 Feb 2003 20:20:07 +0000

I only just got a chance to give this a go and I'm afraid it hasn't
helped. In fact it is exactly the same as it was before but now I get
lots of warnings saying things like:

TimerManager.m:49: warning: passing arg 6 of
`timerForController:type:target:selector:repeats:timer:' from
incompatible pointer type
TimerManager.m:102: warning: invalid receiver type `NSTimer **'


I know it might be my fault. This is uncharted territory for me.

Colin

On Friday, February 14, 2003, at 09:18 am, Jirtme Laurens wrote:

>
> Le vendredi, 14 fiv 2003, ` 09:40 Europe/Zurich, Colin Jackson a icrit
> :
>
>> And here is the full method:
>>
>> - (void) timerForController:(NSString *)controller type:(NSString
>> *)type target:(id)target selector:(SEL)aSelector
>> repeats:(BOOL)doesRepeat timer:(NSTimer *)timer {
>> double delay;
>> if ([Defaults itemActive:type inController:controller]) {
>>
>> delay = [Defaults getDoubleStateForKey:[[controller
>> stringByAppendingString:type]stringByAppendingString:@"Time"]];
>> if ([[Defaults getStringForKey:[[controller
>> stringByAppendingString:type]stringByAppendingString:@"Unit"]]
>> isEqualToString:@"Minutes"]) {
>> delay *= 60;
>> }
>> NSLog(@"about to check validity");
>> if ([timer isValid]) {
>> NSLog(@"Timer is valid");
>> if (!doesRepeat) {
>> NSLog(@"and doesn't repeat");
>> [timer invalidate];
>> timer = [NSTimer scheduledTimerWithTimeInterval:delay
>> target:target selector:aSelector userInfo:[controller
>> stringByAppendingString:type] repeats:doesRepeat];
>> timer = [timer retain];
>> }
>> }
>> else {
>> NSLog(@"Timer isn't valid");
>> NSLog([controller stringByAppendingString:type]);
>> timer = [NSTimer scheduledTimerWithTimeInterval:delay
>> target:target selector:aSelector userInfo:[controller
>> stringByAppendingString:type] repeats:doesRepeat];
>> timer = [timer retain];
>
> As timer is a local variable, you will never get a chance to release
> it.
> You should pass timer by reference replacing
>
> (NSTimer *) timer
>
> by
>
> (NSTimer **) timerPtr
>
>> - (void) timerForController:(NSString *)controller type:(NSString
>> *)type target:(id)target selector:(SEL)aSelector
>> repeats:(BOOL)doesRepeat timer:(NSTimer **)timerPtr
>
> BTW, I first thought that your function was returning a timer for the
> controller. The following API seems to be more appropriate to your
> method.
>
> - (void) updateTimer: (NSTimer **) timerPtr forControllerKey:
> (NSString *) key target: (id) target selector: (SEL) selector repeats:
> (BOOL) yorn;
>
>
>> }
>> }
>> else {
>> if ([timer isValid])
>> [timer invalidate];
>> }
>> }
>>
>>
>> I hope this helps.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: NSTimer and call-by-reference (From: Jérôme Laurens <email@hidden>)

  • Prev by Date: Re: AddressBook searching broken in 10.2.4
  • Next by Date: RE: SomebodyPleaseHelpMe - sample Java bridge test
  • Previous by thread: Re: NSTimer and call-by-reference
  • Next by thread: [NSString stringWithContentsOfURL:] question
  • Index(es):
    • Date
    • Thread