sizeWithFont method is deprecated. boundingRectWithSize returns an unexpected value

How about create new label and using sizeThatFit:(CGSize)size ?? UILabel *gettingSizeLabel = [[UILabel alloc] init]; gettingSizeLabel.font = [UIFont fontWithName:@”YOUR FONT’s NAME” size:16]; gettingSizeLabel.text = @”YOUR LABEL’s TEXT”; gettingSizeLabel.numberOfLines = 0; gettingSizeLabel.lineBreakMode = NSLineBreakByWordWrapping; CGSize maximumLabelSize = CGSizeMake(310, CGFLOAT_MAX); CGSize expectSize = [gettingSizeLabel sizeThatFits:maximumLabelSize]; Edit: This upper code is not good for ios 7 and above, … Read more

Converting NSString to NSDictionary / JSON

I believe you are misinterpreting the JSON format for key values. You should store your string as NSString *jsonString = @”{\”ID\”:{\”Content\”:268,\”type\”:\”text\”},\”ContractTemplateID\”:{\”Content\”:65,\”type\”:\”text\”}}”; NSData *data = [jsonString dataUsingEncoding:NSUTF8StringEncoding]; id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; Now if you do following NSLog statement NSLog(@”%@”,[json objectForKey:@”ID”]); Result would be another NSDictionary. { Content = 268; type = text; }

URLWithString: returns nil

You need to escape the non-ASCII characters in your hardcoded URL as well: //localisationName is a arbitrary string here NSString* webName = [localisationName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString* stringURL = [NSString stringWithFormat:@”http://maps.google.com/maps/geo?q=%@,Montréal,Communauté-Urbaine-de-Montréal,Québec,Canadae&output=csv&oe=utf8&sensor=false”, webName]; NSString* webStringURL = [stringURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSURL* url = [NSURL URLWithString:webStringURL]; You can probably remove the escaping of the localisationName since it will be handled by … Read more

iPhone XMLRequest

You can use libxml2. I suspect it is the fastest approach. Add its framework to your project (see the “setting up your project” section of this document). In the header of your XML writer, add the following imports: #import <libxml/encoding.h> #import <libxml/xmlwriter.h> In the implementation, write a method to generate your XML. Presumably you’ll be … Read more

How do I get word wrap information with the new iOS 7 APIs?

Example: CGFloat maxWidth = 150; NSAttributedString *s = [[NSAttributedString alloc] initWithString:@”The quick brown fox jumped over the lazy dog.” attributes:@{NSFontAttributeName:[UIFont fontWithName:@”GillSans” size:20]}]; NSTextContainer* tc = [[NSTextContainer alloc] initWithSize:CGSizeMake(maxWidth,CGFLOAT_MAX)]; NSLayoutManager* lm = [NSLayoutManager new]; NSTextStorage* tm = [[NSTextStorage alloc] initWithAttributedString:s]; [tm addLayoutManager:lm]; [lm addTextContainer:tc]; [lm enumerateLineFragmentsForGlyphRange:NSMakeRange(0,lm.numberOfGlyphs) usingBlock:^(CGRect rect, CGRect usedRect, NSTextContainer *textContainer, NSRange glyphRange, BOOL *stop) … Read more