• 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: UnitTest: object Should be Dealllocated
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: UnitTest: object Should be Dealllocated


  • Subject: Re: UnitTest: object Should be Dealllocated
  • From: Andreas Grosam <email@hidden>
  • Date: Wed, 26 Jun 2013 17:56:04 +0200

On 26.06.2013, at 16:55, Kyle Sluder <email@hidden> wrote:

> On Jun 26, 2013, at 6:15 AM, Andreas Grosam <email@hidden> wrote:
>
>> There is a class whose implementation may be prone to accidentally have a _strong_ reference elsewhere (namely within a block), which effectively prevents the object to be deallocated in certain scenarios when it should.
>>
>> When carefully implemented that doesn't happen, though.
>>
>>
>> How can I create a Unit Test which tests such cases, e.g.:
>>
>> Foo* foo;
>> @autoreleaspool {
>>   foo = [Foo new];
>>   [foo doSomething];
>>   foo = nil;   // should deallocate foo
>> }
>> ASSERT_DEALLOCATED_TRUE(foo);
>>
>>
>> Of course, the "doSomething" is more complicated involving possibly suspended dispatch queues and blocks, etc.
>
> Create a __weak reference to foo and assert that it is nil?

Yes that works!  Thanks, Kyle!

>
> --Kyle Sluder


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >UnitTest: object Should be Dealllocated (From: Andreas Grosam <email@hidden>)
 >Re: UnitTest: object Should be Dealllocated (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: UnitTest: object Should be Dealllocated
  • Next by Date: UIButton not visible
  • Previous by thread: Re: UnitTest: object Should be Dealllocated
  • Next by thread: Re: UnitTest: object Should be Dealllocated
  • Index(es):
    • Date
    • Thread