-(void)updateResult {
@try {
if (questionFlag == INSERT_IMAGE_DETAILS) {
[self getImageDetail];
[m_ivwMainConsumerImage setImage:[UIImage imageWithContentsOfFile:[NSString stringWithFormat:PROFILE_PHOTO_FILEPATH,[[[DataModel sharedConsumerData] images] lastObject]]]];
}
}
@catch ....
I am new to Objective C and the above code snippet is a part of a program where I am getting the warning: 'More % conversions than data argument' for the line
[m_ivwMainConsumerImage setImage:[UIImage imageWithContentsOfFile:[NSString stringWithFormat:PROFILE_PHOTO_FILEPATH,[[[DataModel sharedConsumerData] images] lastObject]]]];
Can you please let me know how to overcome this error?
Thanks
This error means that your formatting string (PROFILE_PHOTO_FILEPATH
) has more format specifiers than parameters you are providing to it (you are only providing one, the lastObject of the DataModel's images).
For example:
if PROFILE_PHOTO_FILEPATH
is "%@ %d" it expects some object %@ and an integer %d. So you would need to call stringWithFormat:
this way:
[NSString stringWithFormat:PROFILE_PHOTO_FILEPATH, [[[DataModel sharedConsumerData] images] lastObject], 42];
Obviously this is just an example, without seeing the contents of PROFILE_PHOTO_FILEPATH I can't be more specific.
See this document for more details on how string format specifiers work: