objective c - How to store CGContext state in a NSMutableArray? -
i new cgcontext world. need create stack of cgcontext(s) in nsmutablearray.
i have valid pdfcontext created uigraphicsbeginpdfcontexttodata
i'm passing context method argument
-(void) drawto:(cgcontextref) context{}first identify current context with:
cgcontextref curcon = context;nslog value:
context:<cgcontext 0x6b79d60>then attempt make copy of current context:
cgcontextref concopy = uigraphicsgetcurrentcontext();then add nsmutablearray:
[mymutablearray* addobject:(id)concopy];then list content of nsmutablearray:
after object added:<__nsarraym 0x6b7e850>(<cgcontext 0x6b79d60>)
and see added value same context sent method argument , not copy.
what missing here ? or perhaps it's not possible store status of current context in nsmutablearray ? understand paths not saved, that's fine. need save , current context can saved. thank you!
you can't directly. what's real problem you're trying solve? cgcontextsavegstate() you're asking for, within scope of current context. cglayer can create contexts can carry around (though still can't serialize them).
if real goal save non-path state in copyable form, can create copyable object calling cgcontextget... methods , storing results. can call cgcontextset... on them make new context. it's tedious, should not difficult. (though raise question of why. feels odd thing doing.)
Comments
Post a Comment