1

I have an NSMutableArray filled with BeziarPaths. I'd like to serialize it so that its accessible on Python. Someone suggested to me that I can try GZIP + InkML or GZIP +JSON. I was wondering what the best way to do this is. I am also really new to this, so example code would be extremely helpful.

Thanks

5
  • why not SVG? If it's just Bezier Paths, then SVG would be just as good and much better supported, no? Commented Dec 28, 2011 at 21:26
  • SVG seems very interesting. Can anyone refer me to example code showing me how to do it? Commented Dec 28, 2011 at 21:39
  • On second thought, I was wondering if there was a binary format that is compatible for both. Commented Dec 28, 2011 at 22:44
  • @user1120008, there's plenty of documentation on the Internet for using SVG. Commented Dec 29, 2011 at 7:20
  • @user1120008: why would you want a binary format? If it's because of size, SVGZ (zipped SVG) is well supported by many editors. If it's for obfuscation, then you should use your own proprietary binary format; any popular format would have libraries that can access them. Commented Dec 29, 2011 at 14:20

2 Answers 2

1

I recently used protocol buffers to great effect in this particular area. It's got very very little overhead and performs better than the native objective C serialization/deserialization(at least on the ipod touch I'm testing for performance with, since it is the slowest device we want to support).

It took me a while to set them up as a newbie in iOS development though(the python side was really easy though).

This blog post really helps: http://nserror.me/blog/2011/06/03/protocol-buffers-and-xcode/

To summarize on how to integrate protocol buffers into an objective C project -- This took me a whole day to piece together so I'm putting it up in the hope someone in my situation finds it useful:

  • get protocol buffers from here
  • configure/make/make install
  • get this project(that's git clone https://github.com/booyah/protobuf-objc.git for the lazy)
  • autogen.sh/configure/make/make install
  • In protobuf-objc/src/runtime there is an xcode project. Open it, build and then close xcode again. It is really important you do this.
  • open up your project in Xcode. Go to the "build rules" tab in the target. Add a custom build rule for *.proto files.

The script:

/usr/local/bin/protoc --plugin=/usr/local/bin/protoc-gen-objc \ 
--proto_path=${INPUT_FILE_DIR} \
--objc_out=${DERIVED_SOURCES_DIR} \
${INPUT_FILE_PATH}

The output files:

${DERIVED_SOURCES_DIR}/${INPUT_FILE_BASE}.pb.h
${DERIVED_SOURCES_DIR}/${INPUT_FILE_BASE}.pb.m
  • copy the protobuf-objc project into the same directory you have your .xcodeproj in
  • Add a reference to the project in protobuf-obj/src/runtime (just drag into from finder into your project
  • Under "build phases" for your target add a dependency on ProtocolBuffers
  • Under "build settings" select the "all" view and add the following to your header search paths: ${SOURCE_ROOT}/protobuf-objc/src/runtime/Build/Products
  • In the summary for your target, add a link to the .a file generated by the ProtocolBuffers project.
  • And that's it, from now on, you just add your .proto files to the project(and to the list of files to be compiled) and you can use protocol buffers
Sign up to request clarification or add additional context in comments.

Comments

0

Choose what you like most. Both are standards, but JSON is a generic format used for serializing dictionaries and arrays, while InkML focuses on drawing related objects.

JSON support is available in both Python and Objective-C, while InkML has no built-in support in either.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.