250-ld
Getting strange results, especially when opening another person's project on your own maching? Trying deleting the references and reimporting the files.
Getting strange results, especially when opening another person's project on your own maching? Trying deleting the references and reimporting the files.
- (BOOL)writeToFile:(NSString *)path
atomically:(BOOL)useAuxiliaryFile;
Works with:
NSDictionary
NSArray
NSData
NSString
For more complicated purposes, NSOutputStream
might be the best option, but for simply writing a date or even XML this might be the simplest and fasted way.
NSArray *paths = [[NSFileManager defaultManager]
directoryContentsAtPath: NSHomeDirectory()];
// either like that...
NSEnumerator *e = [paths objectEnumerator];
for (NSString *p in e) {
NSLog(@"path: %@", p);
}
// or like that.
for (NSString *p in [paths objectEnumerator]) {
NSLog(@"path: %@", p);
}
NSDictionary has both [myDict objectEnumerator]
and [myDict keyEnumerator]
.
Fast Enumberation is a feature in Objective-C 2.0, it allows you to step over arrays and dictionaries in a fast, consice, and secure (guarded against mutations) manner.
for (NSString *p in paths) {
NSLog(@"path: %@", p);
}
// or
NSString *p;
for (p in paths) {
NSLog(@"path: %@", p);
}
Sometimes things are really as simple as they should be.
Situation For whatever reasons, you want to move a directory from one svn repository to another.
Problem Once in a repository, every folder gets an invisible .svn folder, where the svn info instored. Deleting them by hand can be tedious. A script might be cumbersome.
Solution Use svn to export the folder. Exporting basically means getting rid of the .svn/ folders. http://svnbook.red-bean.com/en/1.0/re10.html
Usage
svn export folder/ exported-folder/
Update What does svn add --force myDirectory do?
Open:
/wp-includes/js/quicktags.js
Change/Add/Delete tags to your likening.
How to link libxml2 in Xcode for use with TouchXML?
Header Search Paths:
/usr/include/libxml2
Other Linker Flags: -lxml2
(Of course assuming, that libxml2 is present at this location on your system.)
In the Target Info, make sure to select the current configuration to see the values. Otherwise you get <Multiple Values> and they look like it's not possible to edit them. Took me a while to figure out, that changing the configuration [top left] was the key. Duh.
Turning Boolean 1, 0 into a more descriptive description:
NSLog(@"data1 is equal to data2: %@", [data1 isEqualToData:data2] ? @"YES" : @"NO");
Following situation Using TouchXML to parse XML data, works without problem on example XML files, but crahes on mine. Problem Empty values in my data set. (sometimes <place>somePlace</place>, sometimes <place></place>)
/* CXMLDocument setup & parsing omitted */
NSString *e = [[resultElement childAtIndex:counter] stringValue];
NSString *k = [[resultElement childAtIndex:counter] name];
[blogItem setObject:e forKey:k];
// crashes when e is empty. Displays a (null), is nil
Solution 1 Check for empty e, replace nil with empty string
// check if element is empty
if ( nil == e ) { // ...or the less elegant (0 == [e length])
e = @"";
}
[blogItem setObject:e forKey:k];
Solution 2 Use setValue instead of setObject, as setObject crashes and burns when it encounters nil, whereas setValue specifically deals only with strings and handles nil gracefully.
[blogItem setValue:e forKey:k];
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.
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
UPDATE instead of adding libxml2.dylib link to the Framework on the system: Other Linker Flags:
-lxml2