Mac / iPhone App Development
Home of a Small Time Developer

Archive for the ‘Development’ Category

  1. iPhone Expat XML Parser Wrapper

    Often in iPhone projects I’ve needed to parse XML documents from the internet.

    I want the data to be processed  and shown to the user as quickly as possible.
    If the file is large I don’t want to have to store the entire contents in memory.

    Using NSXMLParsers initWithURL: method the xml file is downloaded synchronously with NSURLConnection before parsing. If [...]

    • Share/Bookmark
  2. Objective C HMTL Parser

    Here is basic html parser which I’ve used in several projects recently. The code depends on libxml2 and is basically a thin wrapper that provides a more convenient interface for parsing html with objective c. This has only been tested on iphone OS 3.1.3 & 3.2, if your using a OSX your probably better of [...]

    • Share/Bookmark
  3. Reddit.com Clone In 4 Lines Of C

    #include <stdio.h>
    #include <time.h>
    #include <netinet/in.h>
    typedef struct { int ID; char * title; char * link; char * date; int upVotes; int downVotes; void * next; } Article; Article * root; char * getVal(char * query, char * key) { char * str = malloc(1); int match = 0; int pMatch = 0; char * cur = [...]

    • Share/Bookmark
  4. Multithreading with core Data

    Working with core data in a multi threaded environment you have to extremely careful
    For example if were creating a news application, we want to be able to import news in the background and display updates to the user with no interruption of the GUI. The task can be divided into several stages:

    Download the xml feed [...]

    • Share/Bookmark
  5. Adding Reachability Code to your app

    Ok so iVersion 1.4 was declined due to not loading correctly when their is no network connectivity.
    When the device is connected to a cellular network, iVersion does not load its contents.  After the user enters the URL (http://svn.collab.net/repos/svn/trunk/) and taps “connect,” an error message is received.
    Apparently the error message is not clear enough or something, anyway this [...]

    • Share/Bookmark
  6. UIKit Modal Prompt

    in order to not lock the ui iVersion runs it’s svn commands in a seperate threads. The promblem arises when one of thses threads needs to prompt for a value e.g. a username / password. Firstly UIKit does not provide a modal alert view and secondly UIKit should only be called from the mainThread.
    First we [...]

    • Share/Bookmark
  7. iPhone File System Monitor

    I require simple for system monitoring for a new (undisclosed) iphone project. It doesn’t appear that there is any equivilant to ionotify for the iphone, so I whipped up this polling file system monitor which meets my basic requirements. If you find this code useful feel free to use / distribute etc.

    #include "FileSystemMonitor.h"
     
    //Setup the monitor
    FileSystemMonitor [...]

    • Share/Bookmark
  8. Dynamic Arrays with C

    In the final push to add syntax highlighting to iVersion I have been working on optimising the parser.
    In the inner parsing loop I have been using the standard NSMutableArray to keep track of various objects and tokens. Objective C message passing is of course an order of times slower than a C function call, even [...]

    • Share/Bookmark