Re: How to encode STL vector
Re: How to encode STL vector
- Subject: Re: How to encode STL vector
- From: Dan Crevier <email@hidden>
- Date: Wed, 06 Nov 2002 21:50:16 -0800
On 11/6/02 5:14 AM, "Clark S. Cox III" <email@hidden> wrote:
>
On Wednesday, Nov 6, 2002, at 04:46 US/Eastern, Arthur Clemens wrote:
>
>
> I was wondering how to encode a vector type using NSCoding?
>
> I have a vector of unsigned ints.
>
>
You can encode it just like you would a plain C array:
>
>
//Encode
>
const unsigned size = myVector.size();
>
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &size];
>
[aCoder encodeArrayOfObjCType: @encode(unsigned) count: size at:
>
&myVector.front()];
I think you want &myVector[0] instead of &myVector.front(). Using front()
assumes that the iterators for vectors are simple pointers.
Dan
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.