0

I've been working on some code with another developer that is working remotely. So far, their code has been filled with bugs and is poorly put together... upon further inspecting some of their code, I came upon something I'd not seen anyone else do (of course I'm not an expert in iOS and find new things every day).

In one of the properties they declared, it was written as

@property (nonatomic, strong, getter = thenewPasswordActivity) IBOutlet UIActivityIndicatorView * newPasswordActivity;

I was able to find that they were overriding the custom getter method from this post, but was stumped as to why because not once was "thenewPasswordActivity" used.

So this being said, my main question is what was the overall gain from defining a custom getter method like this. Would this custom getter allow one to access the property without using self.newPasswordActivity (without synthesizing) and instead just reference thenewPasswordActivity?

Community
  • 1
  • 1
c_rath
  • 3,618
  • 2
  • 22
  • 14
  • AFAIK, it'd just change the name of the getter. – duci9y Jul 07 '14 at 17:13
  • Thanks for responding. That's what I assumed, but it seemed pointless when it wasn't used and she used self.blablabla about 20 different times. =/ – c_rath Jul 07 '14 at 17:24
  • I'm not sure though, so I suggest you wait and see if anyone counters what I think. – duci9y Jul 07 '14 at 17:25

1 Answers1

2

It actually makes sense. From the Transitioning to ARC Release Notes:

You cannot give an accessor a name that begins with new. This in turn means that you can’t, for example, declare a property whose name begins with new unless you specify a different getter:

// Won't work:
@property NSString *newTitle;
// Works:
@property(getter=theNewTitle) NSString *newTitle;

Of course you could rename the property instead and choose a different name that does not begin with "new"...

Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382
  • HA! Okay thanks! I totally didn't even notice the name started with new. Yeah better naming conventions on that one would have been so much simpler. – c_rath Jul 07 '14 at 17:32