Showing posts with label xml. Show all posts
Showing posts with label xml. Show all posts

Wednesday, 26 September 2007

xml bindings

So it occurs to me that after looking at some of the cocoa xml examples, I can bind the pulldown options for the search filters, directly into my xml document request.



I'm not totally clear how to do this but it looks like more interesting fun.

Saturday, 15 September 2007

Retain Release Revolt - Bring Me Leopard Objective c2.0

So I ripped out the Ruby and got my new project running and have been writing the methods that were done in Rubycocoa

The only trouble is.... You do an ebay search and it produces the right results. Try again and it produces nothing. Open a web address, it works. Try again it crashes.

I now have to wrap my head around memory management properly. I understand what I'm supposed to be doing but I need to go into my code and start working out where to retain/release/autorelease. Having come back from Ruby, I find myself longing for Objective C2.0.

The bit that I need to take on board is where objects are retained automatically by adding to collections and when to release the collections and create a fresh object.

It's not rocket science, but I'd prefer not to have to do that kind of thing.

Garbage Collection I <3 you.

I went to an Apple Leopard Dev event last Winter and the stuff on Objc2.0 was cool, I can't believe I'm under NDA. actually I'm not because they forgot to ask anyone to sign it, but everything I know is already on Apple's website anyway.

October can't come soon enough.

Things I'd like to see in Leopard for dev's
Easier syntax for arrays and dictionaries.
Yes its not that bad now, but Ruby is so much clearer ( like most languages )
howabout
NSArray* myarray = @( obj1, obj2, obj3 )
or
NSDictionary *mydict = @{ obj1, @"obj1", obj2, @"obj2 }

That would be nice and fast

  • CoreData connecting easily to mysql

  • Set/Get creation syntax.

  • Set/Get that works with keypaths. Then I wouldnt need to type


    [ myobject valueForKeyPath:@"path.path" ], instead I could use [ myobject.path.path ]




Stuff that we know is coming from Apple's website


  • Easier array iterators. Thats welcome. I love Rubys Array.each{| element | code }

  • Garbage Collection - yay

  • Easier accessors - yourobject.value really those []'s get a bit of a mouthful sometimes

  • Better error hiliting in xcode, yay. I love textmate, wish xcode was a bit more like that.

  • Core animation I want to do a spinner, praps this will be the best way




Update, how easy was a spinner, duh!

Thursday, 13 September 2007

import xml into NSDictionary

I've spent the last few days fiddling on an NSXMLNode category that creates a method called

xmlToDictionary

+(NSDictionary) xmlToDictionary:node


You just give it an xml node and it returns a dictionary that you can query like this...


xmlDictionary = [ XMLNode xmlToDictionary:rootNode ];


value = [ xmlDictionary valueForKeyPath:@"SearchResultArray.SearchResultItem" ]



I thought when the documentation said that NSXMLNode was kvc compliant that it would do this, but it didnt mean that it meant stuff like [ rootNode valueForKey:@"children" ] which is obvious really.

I also thought there must be a way to do the above, and there still might be, but I didnt find it.

I looked at using XPath and that is a solution. I also looked at applying an XSLT sheet against the XMLDoc and using that to convert to plist format and then reading that into NSDictionary. But I dont know XSLT and thought this was an interesting method to write.

I also wrote another category method nodeForPath:(NSString*)path that does a similar job but simply parses a path like "SearchResultItemArray.SearchResultItem" and produces the value on the fly. Actually its probably better to do it like that.

I'm experimenting with native NSXMLNode methods and my own ones to see which is easier and clearer to read.