How to compress a file without using any external libraries? - objective-c

I need to be able to compress file in an iPhone/iPad application. I know there are a few libraries out there that have this problem solved and are easy to integrate in an application, but I was wondering if there is something already implemented in Cocoa. It would help me a lot if I did not need to integrate external libraries in my project.

Do you mean something in iOS / objective-c ? If so, you do know that most objects you are using is an 'external library' i.e. the Foundation framework?
There is, shipped with every iPhone, libz which is the library for zipping / unzipping. You just include it as if it were any other framework.
However, the chances that you will, first time, use it as bug free as an existing library that's been tested for years by hundreds of other developers is slim.
Personally, I would easily choose adding a library over writing my own for something like this - it's been done before, you're just wasting time re-writing it. Try ZipArchive for a one-liner to unzip files etc. Just copy the source code into your app and press build :)

I don't think there is something like that in cocoa inbuild .. but you should have a look here - https://bitbucket.org/kolpanic/zipkit/wiki/Home

Related

How can I distribute my objective c library with source code embedded

I would like for people to be able to debug my library, should they feel like they want to.
For this I think a good idea would be to embed the source in the library / framework itself. Does Xcode support this option?
For reference of what I’m looking for, in Java you can build a Jar file which comes with the attached source code (and optional javadoc) embedded within the library https://stackoverflow.com/a/5064833/48062
Xcode does not support this option, no. Your best bet would be to upload the source to Github (https://github.com) and include the link in your documentation for the framework. That way you can be sure that your users can always get to the freshest, most up to date, code.

upgrading to Automatic Reference Counting and cleaning up my code

I have a project from 2 years ago that I'd like to bring back into action in xcode.
Is there a simple way to do away with the old style memory management I have in there with retain/releases and use the new .. ARM?
And this is a 32bit app using the QTKit and QuickTime frameworks - can this become a 64bit app that I can put on the App Store one day if it works well?
Also I realise that my app is one enormous .h and .m file - i'd like to break it into smaller files to make it easier to read and find what i am doing - any tips on how to do that?
Thanks guys!
Adam
Use the Xcode menu item Edit->Refactor->Convert To Objective-C ARC which can automatically convert everything to ARC.
You can also use Edit->Refactor->Convert to Modern Objective-C syntax to update the code to use the new array/dictionary/number literal syntax.
For breaking out one file into many, Xcode's built-in refacting support is pretty terrible. You can try out Jetbrains Appcode which has much better support for this kind of thing.

Generate Objective-C code from any other language

Are there frameworks/generators for producing iOS code from any other language?
A dynamic language like JavaScript, ruby or Python are preferred. Googling for iOS code generators was largely fruitless.
The problem with systems like PhoneGap is that their output is a full-fledged application. What I need to produce is a library (.a & .h file eventually) that other Objective-C developers can reuse in their projects.
RubyMotion may or may not do what you want. I haven't seen much about the practicalities of it yet, but I'm thinking since it's statically compiled chances are good that it can produce libraries that can be simply linked into Objective-C projects. One might need another tool to produce the header files.
Of course, this is all speculation.
I think the best solution for what you're looking for is Titanium. It has its own sdk (in JavaScript), a complete IDE and allows you to have one codebase for all major platforms (iOS, Android included). What it's really awesome is the fact that it actually generates native code (a valid XCode project or a Java one for Android). It's also free and open source. Definetely worth a look.
I've never seen code generators, but there are a variety of "spoofs" as it were.
http://xamarin.com/monotouch - iOS on C#
http://phonegap.com/ - iOS on HTML, CSS , Javascript
http://ipodtoucher55.blogspot.com/2010/06/how-to-create-iphone-apps-in-flash-cs5.html - one of several tutorials for flash on iOS
I've seen links to python libraries and I think java too.
When it comes down to it though, they're all work arounds, not direct development.

porting from ios to windows

I'm about to write code for Windows that has somewhat similar functionality to the one existing in already written application for iPhone. I'm thinking of separating common functionality to form a component and compile it to both to iPhone and to Windows. This code is written in Objective C and uses RestKit and Core Data (and probably sqlite). Is compiling it for Windows a viable task? As I understand it GCC could compile Objective C on Windows but I'm unsure about the RestKit and Core Data api availability on Windows. I have seen two names that could be of use: GNUStep and Cocotron but I don't know if they will play well together with RestKit.
Note: I have no idea about iOS development so I might be confusing things. Any help is appreciated.
You will not easily be able to share this functionality between your applications. CoreData uses a custom opaque (not documented) format for the sql store. You would be hard pressed to reverse engineer this.
You will probably save a lot of time by rewriting that part for windows, rather than trying to get it working. There really isn't much iOS code that can be reused under windows, unless you have written pure C or C++.

Objective-C in Mono

I have a .NET application, which I want to port to OSX. Up to now I used a DirectShow DLL for WebCam handling. Can I use an Objective-C DLL for Mono? How? I'm a newbie on Mac. Is there an existing (WebCam handling) solution for this? Is there a better solution?
You want to use the QTKit framework to do this, in particular you can use the QTCaptureView as a reusable NSView that you can embed in an existing window or in an application to do the actual video capturing.
I have just added support for capturing to the MonoMac bindings a few minutes ago after I saw your question, so you will need to do a little bit of work.
Steps:
Install Mono, MonoDevelop and the MonoMac addin as described here: http://mono-project.com/MonoMac
Download the latest sources for MonoMac and MacCore from Github: http://github.com/mono/maccore and http://github.com/mono/monomac
Update the MonoMac.dll to the latest version, by going into the monomac/src directory and typing "make update"
At this point you should be able to use the QTCaptureView in your MonoMac applications like any other NSView. A tutorial showing the use of the API in Objective-C is here:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/QTKitApplicationTutorial/BuildingaSimpleQTKitCaptureApplication/BuildingaSimpleQTKitCaptureApplication.html#//apple_ref/doc/uid/TP40008155-CH8-SW1
You can just use the equivalent versions in C#
I'm not sure what you mean by "an object-c dll for Mono".
Your absolute best approach is to learn the platform you're targeting and port only the logic and general architecture.
To access cameras, microphones, line-ins, etc. on Mac OS X, use QTKit (Quicktime Kit). It's mind-numbingly simple to set up a web cam view, record to files, grab frames, etc. It's built in and designed to make this sort of thing mostly drag-and-drop for developers.
MonoMac is just one alternative. There are Monobjc, CocoSharp, NObjective, MObjc / MCocoa and ObjC# (I cannot choose between them). Theese are all "bridges" between Mono and Cocoa, what mean you can use Cocoa API in Mono application. But I don't want to use the API directly. I just want a dinamically linked library, which provide me some function for WebCam handling (as I said, I did this up to this time on Windows). In other words: I need a wrapper in Mono for QTKit.
PS: If I rewrite the application in object-c that means several months, and double work in the future when the application will grow. I love object-c but I hate to work unnecessary.
I tried the accepted code in XCode, and when I tried to port to Monodevelop, several classes are missing, eg. QTCaputureSession, QTCaputreDeviceInput, CVimagebuffer.
(Sorry, I cannot edit my previous messages, this is another account.)