Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Slick's Definitive Guide To Properties

124»

Replies

  • BrianSlickBrianSlick Treadmill Desk Ninja Posts: 10,689Tutorial Authors, Registered Users @ @ @ @ @ @ @ @
    edited August 2011
    Don't crap on my thread, bro.
    Professional iOS App Development. Available for hire.
    BriTer Ideas LLC - WWW | Facebook | Twitter | LinkedIn

    BTIKit | BTICoreDataKit | SlickShopper 2 | Leave a PayPal donation
  • JoeAppsJoeApps Posts: 10Registered Users
    edited August 2011
    BrianSlick wrote: »
    Don't crap on my thread, bro.

    Ha ha! I promise...I won't crap on your thread.

    Anyways, you agree with what I have said? Everyone thinks about things a little differently and I was just giving my view on the subject.

    Hope all is well,
    - Joe<br />
    <a href="http://j.mp/qSEEHO"; target="_blank">/*** My Apps ***/</a><br />
    <a href="http://j.mp/lDwBug"; target="_blank">prankcaller-m
  • BrianSlickBrianSlick Treadmill Desk Ninja Posts: 10,689Tutorial Authors, Registered Users @ @ @ @ @ @ @ @
    edited August 2011
    What's to agree with? You gave a longer answer to a question that was answered a really long time ago (you seem to like digging through old threads - there are plenty of newer threads that need attention), didn't really answer the question that was asked, didn't really say anything that hasn't already been said in this thread, and in addition to being a lame ripoff of the honey badger, your analogy doesn't really clear things up.
    Professional iOS App Development. Available for hire.
    BriTer Ideas LLC - WWW | Facebook | Twitter | LinkedIn

    BTIKit | BTICoreDataKit | SlickShopper 2 | Leave a PayPal donation
  • JoeAppsJoeApps Posts: 10Registered Users
    edited August 2011
    Ok. Thanks for the feedback. Didn't know about the honey badger...will have to check that out!
    - Joe<br />
    <a href="http://j.mp/qSEEHO"; target="_blank">/*** My Apps ***/</a><br />
    <a href="http://j.mp/lDwBug"; target="_blank">prankcaller-m
  • equiinfernoequiinferno Posts: 2New Users
    edited March 2012
    Hello everyone, especially Slick,
    I've been a lurker for quite a while but I just registered to reply to this thread. It's the ultimate eye-opener. If what you say is true, I have to do some serious overhauling to my code-base. Before I do so, I have two questions:

    1) Does all of this still apply with ARC enabled?
    Specifically, this pattern:
    Figure 13
    - (void)viewDidLoad
    {
       MyClass *newItem = [[MyClass alloc] init];    // Create it
       [self setMyProperty: newItem];                // Do something with it
       [newItem release], newItem = nil;             // Get rid of it, ASAP
    }
    
    ?

    Im guessing yes, hence my second question:
    2) Why does the Leak-Instrument not show any leaks allthough I'm doing everything wrong?
    As it seems, I've been wildly mis-using & confusing ivars/properties and doing faux pas like this again and again:
    self.anIvarArray = [[NSMutableArray alloc] init];
    My apps hardly ever crash on the simulator or while profiling via Instruments (Leaks). They run rather stable. However, I do experience lots of random crashes on devices.

    Why don't any of these leaks show in the Leak-Instrument? Do these faux pas produce super stealthy-sneaky leaks that the Leak-Instrument doesn't show??

    Thank you very much in advance for your help!!
  • BrianSlickBrianSlick Treadmill Desk Ninja Posts: 10,689Tutorial Authors, Registered Users @ @ @ @ @ @ @ @
    edited March 2012
    1) Does all of this still apply with ARC enabled?
    Specifically, this pattern:
    Figure 13
    - (void)viewDidLoad
    {
       MyClass *newItem = [[MyClass alloc] init];    // Create it
       [self setMyProperty: newItem];                // Do something with it
       [newItem release], newItem = nil;             // Get rid of it, ASAP
    }
    
    ?

    If you try doing this code in ARC, you will get an error on the 3rd line because release is not allowed in ARC. So you can remove the 3rd line. Otherwise, it still basically applies.

    Since you can't do autorelease in ARC either, then your code below is also acceptable.

    Properties in general aren't quite as important under ARC, but IMO are still a good idea to use.
    Im guessing yes, hence my second question:
    2) Why does the Leak-Instrument not show any leaks allthough I'm doing everything wrong?
    As it seems, I've been wildly mis-using & confusing ivars/properties and doing faux pas like this again and again:
    self.anIvarArray = [[NSMutableArray alloc] init];
    My apps hardly ever crash on the simulator or while profiling via Instruments (Leaks). They run rather stable. However, I do experience lots of random crashes on devices.

    ARC: No problem
    Not-ARC: This is a leak.

    Also, leaks don't cause crashes, or at least not quickly. It is over-releases that will crash.
    Professional iOS App Development. Available for hire.
    BriTer Ideas LLC - WWW | Facebook | Twitter | LinkedIn

    BTIKit | BTICoreDataKit | SlickShopper 2 | Leave a PayPal donation
  • equiinfernoequiinferno Posts: 2New Users
    edited March 2012
    Slick, thank you for your quick reply!!
    Huh, so that means (as I am using ARC throughout all projects) I'm actually not doing anything wrong (at least in that regard).
    Properties in general aren't quite as important under ARC, but IMO are still a good idea to use.
    Could you please elaborate a bit on this? I'm wondering: Is it worth the effort to make sure that I'm using properties throughout all my projects (couple thousand lines of code)?
    I'd be highly interested in a "Slick's Definitive Guide To Properties with ARC enabled" :))
  • BrianSlickBrianSlick Treadmill Desk Ninja Posts: 10,689Tutorial Authors, Registered Users @ @ @ @ @ @ @ @
    edited March 2012
    Well, read the thread. One of the key points I make here is that properties help with memory management. That's what ARC does, too. So, the importance of that particular aspect of properties is reduced under ARC. But this is not the only thing that properties are good for, so you should continue to use them.

    As to whether or not you should rewrite a bunch of code, I can't answer that for you.
    Professional iOS App Development. Available for hire.
    BriTer Ideas LLC - WWW | Facebook | Twitter | LinkedIn

    BTIKit | BTICoreDataKit | SlickShopper 2 | Leave a PayPal donation
  • fhsjaagshsfhsjaagshs Posts: 93Registered Users
    edited May 2012
    Very useful. Solved many of my problems.
    <b><b>My apps</b></b><br />
    <a href="http://itunes.apple.com/us/app/rest-counter/id464985741?ls=1&mt=8"; target="_blank">Rest Counter - Count bars of rest in orchestra with ease!!!</a><br />
    <a href="http://itunes.apple.com/us/app/swiftload/id4697629
  • JonasKJonasK Posts: 31New Users @
    edited September 2012
    Dude ! You made my day so much better ! :D
    I must have been leaking everywhere! :P
    Post edited by JonasK on
124»
Sign In or Register to comment.