• 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: warning:assignment from distinct Objective-C type
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: warning:assignment from distinct Objective-C type


  • Subject: Re: warning:assignment from distinct Objective-C type
  • From: David Duncan <email@hidden>
  • Date: Wed, 1 Jul 2009 09:38:36 -0700

On Jul 1, 2009, at 9:26 AM, David Blanton wrote:

I have searched and find nothing that helps with the subject line warning.

	in .h file

	NSMutableArray *m_sources;

	in .mm file

if(m_sources != nil) [m_sources release];

Unnecessary, sending messages to nil does nothing so checking for nil is just a waste of time here.


m_sources = [volumes stringsByAppendingPaths:[defaultManager directoryContentsAtPath:volumes]];

You declared m_sources as an NSMutableArray, but your assigning it an NSArray here. Since an NSMutableArray is a subclass of NSArray and not the other way around, that is why you are getting the error.


	[m_source retain];

note if I do not release / retain m_sources the program crashes with exec bad access


Correct. If you don't understand why, I recommend reviewing the Cocoa Memory Management Guidelines at <http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html >
--
David Duncan
Apple DTS Animation and Printing


_______________________________________________

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: 
 >warning:assignment from distinct Objective-C type (From: David Blanton <email@hidden>)

  • Prev by Date: Re: warning:assignment from distinct Objective-C type
  • Next by Date: Re: warning:assignment from distinct Objective-C type
  • Previous by thread: Re: warning:assignment from distinct Objective-C type
  • Next by thread: Re: warning:assignment from distinct Objective-C type
  • Index(es):
    • Date
    • Thread