It was my mistake in code. I had to initialze img
to some UIImage
on declaration.
Below is shown what was the issue.
UIImage * img; // Image not initialized
// This condition was not satisfied and hence `img` was not storing any time.
if (condition)
{
img = ...;
}
// Below condition should have been satisfied if `img` was not initialized.
// But it did not. I am not getting why.
if (!img)
{
NSLog(@"Image is nil");
}
[tabBarItem setImage:img];