iOS Dev
30 十月 2011 | View Comments
If you have some async task running in background, and you need wait this background task until it finished, code below will help u:
NSDate *loopUntil = [NSDate dateWithTimeIntervalSinceNow:0.1];
while (![self isFinished] && [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode beforeDate:loopUntil]) {
loopUntil = [NSDate dateWithTimeIntervalSinceNow:0.1];
}
Tagged in cocoa, NSRunLoop, objecitive-c
Restkit,RubyOnRails,iOS Dev
28 十月 2011 | View Comments
If you are using Rails as your backend, Reskit will have trouble to parse ActiveRecord timestamp.
Default ActiveRecord timestamp JSON out is 2008-12-29T00:27:42-08:00
You can not convert it to NSDate directly use NSDateFomatter
you must convert it to 2008-12-29T00:27:42-0800
But you have not chance to convert when you use Restkit Mapping.
Here is my solution
1. Monkey patch Time and DateTime class
class Time
def as_json(option=nil)
self.strftime("%Y-%m-%dT%H:%m:%S%z")
end
end
class DateTime
def as_json(format=nil)
self.strftime("%Y-%m-%dT%H:%m:%S%z")
end
end
2. Add default date fomatter to RKObjectMapping
NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
[RKObjectMapping addDefaultDateFormatter:dateFormatter];
Tagged in activerecord, NSDateFomatter, Restkit
iOS Dev,ruby
28 十月 2011 | View Comments
I can not install gem after installed xcode 4.2. It throws bus error.
the problem is xcode replace gcc with llvm-gcc
How to fix it:
1. Install standalone gcc
http://cloud.github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.7-v2.pkg
2. add gcc environment in your bash
export CC=/usr/bin/gcc-4.2
Tagged in gcc, xcode
Three20,iOS Dev
6 十月 2011 | View Comments
Thee20 is very good framework.
The features of TTImageView
1. Load image from remote
2. Support default image
3. Cache image, so you don’t need load it again.
4. Support reload image
Find more to read source code of TTImageView
#import <Three20/Three20.h>
TTImageView *productImage = [[TTImageView alloc] initWithFrame: CGRectMake(30, 30, 70, 70)];
[productImage setUrlPath:@"http://a-image-url"];
[productImage setDefaultImage:[UIImage imageNamed:@"default_product_small.png"]];
Tagged in iPhone, Objective-c, Three20, TTImageView, UIImageView