• 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: NSMutableArray to NSArray?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableArray to NSArray?


  • Subject: Re: NSMutableArray to NSArray?
  • From: Glen Simmons <email@hidden>
  • Date: Thu, 4 Oct 2007 12:41:14 -0500

To expand on what Clark and Daniel said, this is one of the core principles of object oriented programming - polymorphism. See http:// en.wikipedia.org/wiki/Object-oriented_programming, etc..

Even though it's not likely to solve your problem, you can create an NSArray from an NSMutableArray with any of the following:
- copy
-[NSArray initWithArray:]
+[NSArray arrayWithArray:]


These will create a new NSArray whose contents are the same as the NSMutableArray. (Normal memory management rules apply)

HTH,
Glen

On Oct 4, 2007, at 12:31 PM, Clark Cox wrote:

NSMutableArray *is* an NSArray, there is no need to convert. Your
problem likely lies elsewhere.

On 10/4/07, Dani <email@hidden> wrote:
Is there a way to create a NSArray from a NSMutableArray? I tried
with methods -writeToFile and -initWithContentsOfFile but I've got a
problem with the encoding of the contents. Better If I explain what
I'm trying to do. I have a NSMutableArray full of NSStrings objects,
in my case of paths to files, and I want to put all these content in
a NSTableView, but the problem is, that NSTableView only accepts
NSArray for dataSource. What can I do to solve my problem?

About the problems I talk before, I've tried with diferent paths, and
the -writeToFile works fine, but when i execute the -
initWithContentsOfFile the application crash. I had been looking what
was wrong and I discovered that the problem is that
initWithContentsOfFile can't read paths with characters in the
NSString like " ยจ " and others.

Thanks_______________________________________________

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:
40gmail.com


This email sent to email@hidden



--
Clark S. Cox III
email@hidden
_______________________________________________

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:
40gmail.com


This email sent to email@hidden

_______________________________________________

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: 
 >NSMutableArray to NSArray? (From: Dani <email@hidden>)
 >Re: NSMutableArray to NSArray? (From: "Clark Cox" <email@hidden>)

  • Prev by Date: Re: NSMutableArray to NSArray?
  • Next by Date: Re: Z_OPT field in coredata sqlite database. What it is for?
  • Previous by thread: Re: NSMutableArray to NSArray?
  • Next by thread: Re: NSMutableArray to NSArray?
  • Index(es):
    • Date
    • Thread