Dhaval
Dhaval

Reputation: 11

warning: incompatible Objective-C types

Warning: incompatible Objective-C types 'struct NSArray *', expected 'struct UIFont *' when passing argument 1 of 'setFont:' from distinct Objective-C type

Code Like:

lblTemp.font = [UIFont fontNamesForFamilyName:@"Arial"]; // Warning comes here    
lblTemp.font = [UIFont fontWithName:@"Arial-BoldMT" size:13];    
[cell.contentView addSubview:lblTemp];    
[lblTemp release];

Please give some suggestion to solve to it.

Upvotes: 1

Views: 332

Answers (2)

Ben Gottlieb
Ben Gottlieb

Reputation: 85522

-fontNamesForFamilyName: returns an array of font names, not a UIFont. You'll want to pass one of the strings in this array to +[UIFont fontWithName:size:] to get a UIFont object back (as you do in the next line).

Upvotes: 5

taskinoor
taskinoor

Reputation: 46027

[UIFont fontNamesForFamilyName:@"Arial"];
does not return the Arial font, it returns the array of font names for the Arial font family. Check the manual here

Upvotes: 1

Related Questions