Archive for June, 2009
Xml parsing and serialization for Mac OS X and iPhone OS
Apple provides the NSArchiver and NSUnachriver for object serialization / deserialization, but this can not handle any custom xml schema. So filling an object structure with the data of any custom xml schema has to be made manually. Since the iPhone developer community is rapidly growing, a lot of newbie programmer are despairing to deal with the available xml parsing possibilities.
The iPhone SDK only provides NSXmlParser for xml parsing, which is more useful to read certain parts of an xml file, than filling a whole object structure, which really is a pain.
The other possibility is the famous libxml library, which is written in ANSI C - not easy to use for someone who starts programming with objective-c and never learned proper C before. Event there are a lot of wrappers available, dealing with xml can be a pain for newbies.
And here my idea takes place. An XmlSerializer library which fills an object structure automatically could makes it a lot easier and increase the app quality for many programmers. My Idea should work like this:
The xml file:
<Test name="Michael" uid="28">
<Adress street="AlphaBetaGammastrasse 1" city="Zürich" postCode="8000" />
<Hobbies>
<Hobby describtion="blabla"/>
<Hobby describtion="blupblup"/>
</Hobbies>
</Test>
The business objects:
@interface Test : NSObject {
NSString *name;
Adress *adress;
NSArray *hobbies;
int uid;
}
@property (nonatomic, copy) NSString *name;
@property (nonatomic, retain) Adress *adress;
@property (nonatomic, retain) NSArray *hobbies;
@property (nonatomic, readwrite) int uid;
@end
@interface Adress : NSObject {
NSString *street;
NSString *city;
int postCode;
}
@property (nonatomic, copy) NSString *street;
@property (nonatomic, copy) NSString *city;
@property (nonatomic, readwrite) int postCode;
@end
How the xml serializer should work:
XMLSerializer *serializer = [[XMLSerializer alloc] init]; NSData *data = [NSData dataWithContentsOfFile:@"~/Documents/Test.xml"]; Test *test = [serializer deserializeWithData:data];
So I started a project for this idea. If you are interested in, the project can be found here. If you would like to join the project, so don’t hesitate to use the provided mailing list and ask for access.
Around the Lake of Constance
After a quite long non traveling time, we went for a Lake of Constance trip with our bikes on white sunday.
You wont believe it, but we use our bikes the first time since my girlfriend arrived Switzerland. So we decided to remove the dust and pedal the 210 km around the lake.
Day 1
Starting point was Kreuzlingen. Together with our colleagues we head of across the german border to Constance. This is quite near and we already could enjoy the first sight at the lake.

Lake of Constance
We decided not to take the ferry to Meersburg, but to visit the peninsula Mainau and continue via Ludwigshafen to Meersburg.
It took us about half an hour to arrive at the peninsula Mainau. The entry of 8€ is not that cheap just to visit an island, but we wanted to see something on our trip, so we payed and entered to the paradise of the flowers.

Peninsula Mainau
Unfortunately a week before has been this thunder storm, which destroyed most of these wonderful flowers, but there where a lot of birds, restaurants and the butterfly house. The butterfly house was very nice, within a tropical winter garden with a lot of nice orchids and flying butterflies in every color.
After a quick Lunch we continued our trip. The way to Ludwigshafen was very hilly, four hours up and down can be very exhausting, so we where glad to pass Ludwigshafen where we made a small break and continued our way in direction Meersburg.
We arrived in Überlingen at 20:00 so quite late and we searched for rooms, but all hotels in and around Überlingen where fully booked out. With pure luck we finally me a guy from a youth hotel, which just got free space, so we immediately grabbed it.
Day 2
In the second Morning, we visited the pile dwelling museum, where they reconstruct several historical pile dwelling villages and show how they lived in these ancient times.

Pile dwelling museum
Afterwards we arrived in Meersburg, a small city with beautiful old town, where we made a break and discussed our further way. We where very affray that we wont find a room in the second night, because thew day before it was really tight. Finally we decided to drive to Friedrichshafen and take the ferry to Romanshorn, what we did at the end.
The plan was, to driver in direction of Rorschach, if we find a room on the way we’ll stay, otherwise we take the train back home. The pathway to Rorschach is very flat and peaceful. Where the many tourist shops and restaurants have been on the german side, only some fields, forest and a few camping grounds are on the swiss side.
Arbon, somehow, is the swiss counterpart of Meersburg, a small nice city, with a beautiful old town and a castle with the ruins of an ancient roman bath.
And nearby this village we found a small and cheap hotel where we booked our rooms. The hotel just has been renovated and has been clean that you could eat from the floor, very nice.
Day 3
On the third day, we first continued the last 8 km to Rorschach where we made a u-turn and drove back to Romanshorn and afterwards it just has been further 22 km back to Kreuzlingen.
The end of our journey , we enjoyed in Back & Brau in Frauenfeld.