h.and.h
h.and.h

Reputation: 776

In Objective-C, what does this method do?

What does this method do? Why return nil if you want the clock ref? What is the (void)clock part? Happy to delete if this is dumb. I couldn't find the terms to use to find an answer.

- (CMClockRef)clock
{
  (void)clock;
  return nil;
}

and why can't I just do:

- (CMClockRef)clock
{
  return CMClockGetHostTimeClock();
  // Build error: Ivar 'clock' which backs the property is not referenced in this property's accessor
}

Without getting an error?

Upvotes: 2

Views: 259

Answers (1)

Sulthan
Sulthan

Reputation: 130102

The method is a property getter. A property

@property (assign) CMClockRef clock;

is declared somewhere.

That property is backed up by an ivar called clock. This method overrides or implements the property getter to return nil.

Statement

(void)clock;

only silences warning/error saying that the ivar has not been used in the getter.

Upvotes: 2

Related Questions