212NSString and NSMutableString

Should have been clear, but was not:

NSString *s = @"aString";
s = @"anotherString";
NSLog(@"%@", s);
// anotherString

NSMutableString *m = @"aMutableString";
[m appendString:@"andAnAppendedString"];
NSLog(@"%@", m);
// aMutableStringandAnAppendedString

NString allows for the replacement of its whole content by simply assigning a new value.

With NSMutableString it is possible to add/delete/insert strings at arbitrary places in a string.

206NSXMLParser vs libxml2

NSXMLParser parses XML, reports when each node ends, better for very, very large documents.

libxml2 loads whole xml file into memory.

http://code.google.com/p/touchcode/wiki/TouchXML http://code.google.com/p/kissxml/

iPhone SDK Development by Bill Dudney and Chris Adamson

NSXMLParser initWithContentsOfURL: may block GUI while downloading, can not handle HTTP authentication. initWithData: accumulate data with NSURLConnection's delegate -didReceiveResponse, -didReceiveData, -connectionDidFinishLoading.

TouchXML

  • copy TouchXML files to project
  • in "Targets", select target > Get Info > add /usr/include/libxml2 to Header Search Paths - add libxml2.dylib to "Frameworks"

UPDATE instead of adding libxml2.dylib link to the Framework on the system: Other Linker Flags:

-lxml2

Linking libxml2 in Xcode

201Changing NSMutableString into NSString

NSMutableString s; ... -(void)functionA:(NSString )string { [self.s appendString: string]; }

-(void)functionB:(NSString )string { NSString c = self.s; NSString* c = [NSString stringWithString: self.s]; }

"Returns a string created by copying the characters from another given string."

self.s is a refernce to s, might change over time, stringWithString makes a copy, a "snapshot" of self.s...

195UIWebView, Changing filenames with Javascript

Calling JS from webViewDidFinishLoading, modifying paths to local. Before that all the images had to be stored into the local path.

http://iphoneincubator.com/blog/windows-views/uiwebview-dynamically-modify-html-documents

Interesting direction, but still looking for an elegant way to mix external sites (HTML) with local content (images, scripts...)

192Mobile Safari/UIWebView Supported Meta Tags

MetaTags.html

ConfiguringWebApplications.html

<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="none"> <meta name = "viewport" content = "width = device-width"> <meta name = "viewport" content = "initial-scale = 1.0, user-scalable = no"> <link rel="apple-touch-icon" href="/custom_icon.png"/> <link rel="apple-touch-startup-image" href="/startup.png">

188Disable UIWebview vertical bouncing

id scrollView = [yourWebView.subviews objectAtIndex:0]; if( [scrollView respondsToSelector:@selector(setAllowsRubberBanding:)] ) { [scrollView performSelector:@selector(setAllowsRubberBanding:) withObject:NO]; }

It's not a real UIScrollView, therefore 'id'. And other UIScrollView action don't seem to work....

http://stackoverflow.com/questions/500761/stop-uiwebview-from-bouncing-vertically

184Minimal Google

MinimalGoogle
  1. Copy
  2. Paste into Address Bar
  3. Hit Return 4 Reload google.com

(Might not work on google.co.jp) (Delete Google Cooke to restore)

182jWeb / Max5

Webkit-based jWeb in Max5 when used as a sub-patch needs to be opened once to initalize. Possible workaround? Open and close the window on startup?

175Curling Images at Twitter

curl -F 'image=@test.png;type=image/png' -H 'Expect:' -u username:password http://twitter.com/account/update_profile_background_image.xml

hmm nice.

the logical thing to do.

instead of text messages, send images...

update: turning tiling on. curl -F 'image=@test.png;type=image/png' -F 'tile=true' -H 'Expect:' -u username:password http://twitter.com/account/update_profile_background_image.xml

second -F flag creates second form field.

update: same applies to user profile image curl -F 'image=@icon.png;type=image/png' -H 'Expect:' -u username:password http://twitter.com/account/update_profile_image.xml

update: absolute image paths curl -F 'image=@/Users/x/Desktop/icon.png;type=image/png' -H 'Expect:' -u username:password http://twitter.com/account/update_profile_image.xml

there seems to be a bug in the max shell object, preventing cd to work. it also does not like relative paths (~)...

168Google Translate *New & Improved Bookmarklet

if (page == empty) go to Google Translate else Translate Current Page