Copy a Graphic iOS

1740
1
Jump to solution
07-30-2014 02:33 PM
KyleDunaway
New Contributor III

How can I make a copy of an existing graphic, make changes to the copy, and add it as a new feature.

AGSGraphic *newGraphic = oldGraphic;

newGraphic setAttributes(whatever) also changes the attributes of oldGraphic, because of the pointer to a pointer.

How do I just make a copy?

Thanks.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Given you have an old graphic, you can encode to JSON and pass that to the new graphic, will create a copy using JSON.

AGSGraphic *newGraphic = [[AGSGraphic alloc] initWithJSON:[oldgraphic encodeToJSON]];

Hope this helps

Cheers

Al

View solution in original post

0 Kudos
1 Reply
by Anonymous User
Not applicable

Given you have an old graphic, you can encode to JSON and pass that to the new graphic, will create a copy using JSON.

AGSGraphic *newGraphic = [[AGSGraphic alloc] initWithJSON:[oldgraphic encodeToJSON]];

Hope this helps

Cheers

Al

0 Kudos