views:

42

answers:

1

Hi Everyone!

My question is the following,

I have an NSTextView and I want to do 2 things :

  • First save this textview in an NSMutableArray and assign a X,Y position to it in this array.

  • Secondly, get this textview from the NSMutableArray and display it at the position I've set when I saved it in the array.

Anyone have an idea of how do to such things ???

Thank you very much in advance for your answer and if possible give me an example or sample code to do this in xcode.

Bye ! Robin

A: 

First save this textview in an NSMutableArray …

Why?

… and assign a X,Y position to it in this array.

NSArrays aren't two-dimensional; they are one-dimensional, and that dimension is numeric and sequential (i.e., valid indexes are only 0 ≤ idx < count, and existing indexes will change if an object at a lower index is removed).

To map a point to an object, you would need to wrap the point in an NSValue object and use that as the key in a dictionary.

Secondly, get this textview from the NSMutableArray and display it at the position I've set when I saved it in the array.

Again, why? It sounds almost like you're trying to reinvent nibs.

Peter Hosey
My main idea is to store the content of an nstextview somewhere and call it from there and place it at a certain position... and i can not achive that... any idea ?
Sounds like you want to make a model object that has text and position properties, and use archiving to store and retrieve those objects. You can then have your controller create each text view with the properties of each of the model objects.
Peter Hosey
exactly I've found what I wanted thank you !