Aug 27, 2010

Save multiple wallpapers to Photos Album, UIImageWriteToSavedPhotosAlbum

Sure you know about method to copy an image to user photo library:
void UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo);

but if you try to save multiple files at once
for (int i=1; i<=10; ++i)
{
  UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
}

you'll have every second/third file saved or even nothing will be saved. To investigate what's wrong it's required to set complete selector to UIImageWriteToSavedPhotosAlbum:
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo;

looks like this:
for (int i=1; i<=10; ++i)
{
 UIImageWriteToSavedPhotosAlbum(image, self, @selector(savedPhotoImage:didFinishSavingWithError:contextInfo:), nil);
}
 
- (void) savedPhotoImage:(UIImage*)image didFinishSavingWithError:(NSError *)error contextInfo: (void *)contextInfo
{
 NSLog(@"%@", [error localizedDescription]);
}

and then you'll see an error description "write busy" at the log. System just unable to copy files so fast. Yes, you use just a mobile device with limited, but miraculous abilities ;) It isn't 12 Core Mac Pro.

The solution is to copy photos one by one:
  1. create an array of image names, e.g. wallpapers
  2. copy one
  3. catch complete selector
  4. goto #2

Aug 25, 2010

Timer app supporting both iOS 4.x and iPhone OS 3.x

Updating Vipassana app with retina images and iOS 4 support I almost forget about 3.x users. Despite that months were left from iOS 4.0 release we must tranditionally support previous versions for a while. Especially if taking into account iPhone 3G perfomance on iOS 4.0.x, and generally keep silent about rarity iPhone GSM. I know several guys who still use it and love it by the way.

Now I want to show how to organize simple Timer application with both iOS 4 and iPhone OS support.

Aug 2, 2010

User custom color theme for applications (v0.1)

The idea is to create simple and intuitive UI for user custom themes. For example, let user to define own colors of text labels and background. It's need in some of reading applications.

Should it be interesting for all users? I don't know. It could seem too tech/geeky, but user always has a default theme and nobody is forced to customize. Assuming not more 25% of users will need and take advantage of it. Since I'm going to integrate it in Forismatic, I'll be able to post useful statistics some day.

Jul 29, 2010

Helpful primitive #DEFINEs I really like

The most important reason not to use #DEFINE is code readability, imho. Everyone can define own abbriveations and then get dead code. I mean not an Unreachable code, but code that nobody else can support effectively, even an author after months left. It's easy to get addicted and generate shorteners for every partially doubled line.

That's why I propose only helpful #defines I use almost in every project. They look very simple and even obvious. I place them in the precomiled *.pch file to be availabe in all sources.


Jul 13, 2010

Why you may not need an iPhone

It's not a pop talking about iPhone 4 and its mythical or real hardware problems. It's about the iPhone revolution in common.

This is a retelling of a real story where I was asked to advise to buy or not to buy an iPhone. It's necessary to clarify that an iPhone isn't sold in our country, Ukraine, and the mobile internet revolution isn't started yet. I mean there aren't too much people use mobile internet everyday. It's not only because its cost and quality, but also because most of people have no need to communicate so intensively and continuously. Also I should remark that a good internet access penetration grew up last few years only, now it'll take time to understand mobile internet and services.

In spite of this I meet iPhone users everyday on the streets, shops, metro, bus stations, wherever. Could you imagine why they buy it? They don't know about App Store, except IT guys. Most don't use iTunes. I don't mean buying songs and other media, but not using iTunes even to store backups of the data. Never. So why do they buy an iPhone? it's simple, they do because it's modern and somebody said it's cool. I totally believe it's cool, but not it's cool to have. The problem is that some users is/will be disappointed. Not most, because not everybody likes to feel like a fool paid $1000. And when I was asked I had to find the reason people are upset – they bought a mobile phone, but have an iPhone:
I think, you probably don't need an iPhone because:
1. iPhone isn't a mobile phone. 
It's more than isn't a mobile phone only. It does the phone functions indifferently. After years of Nokia-style it looks too complicated or too different and need time to adopt. Battery life time will never be a week, it's usually 1–2 days with often call or long calls.
2. Call function is secondary. 
iPhone and 200.000 App Store applications creates a special way of using. Buying an iPhone you'll have to accept its ecosystem rules. You even will need to know that you should accept them. It's not so obvious in the country without official sales. iPhone helps internet educated people. Other won't find lots of benefits.

Jun 22, 2010

iOS 4.0 released, what's that?

It's a very expected update.


There are so much new features and possibilities that I couldn't decide what to taste first and decided to continue everyday work. Later watching forums comments I see that the first thing everyone wants to do is to update an app by supporting 4.0, but surely it have to run on previous version also, 3.0-3.1. The right way is to open project settings and set:
  • Base SDK - iPhone Device 4.0
  • iPhone OS Deployment Target - iPhone OS 3.0
After recompiling it'll turn to background properly, but still work on 3.0+ versions.