I am using CorePlot to draw different graphs in my application. Then, I would like to save this graph to a jpg file and publish to some social networking site (e.g., Twitter).>
Actually, the CPLayer base class used for all drawing elements in Core Plot has a category method called -imageOfLayer
that returns a UIImage instance of whatever layer you call it on. See the CPPlatformSpecificCategories.h
and CPPlatformSpecificCategories.m
files in the framework if you want to see how this is accomplished.
Simply use -imageOfLayer
on your CPGraph instance and then use UIImageJPEGRepresentation()
to create the JPEG version of that image. You can then upload that image using the normal means.
Likewise, there is a -dataForPDFRepresentationOfLayer
method that returns an NSData instance containing a PDF representation of the layer and its sublayers.