Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top