nsstring

Finding date & time in NSString using Regex

百般思念 提交于 2020-01-03 04:47:10
问题 I want to do something similar to this question: regular expression in ruby for strings with multiple patterns But I want to do it Objective-C . Basically I want extract date and time from a string with a date and time after the @ sign. For example I have a string: Feed the Rabbits @12 , I want to extract the date and time after the @ , the problem is that the string can vary, for example it could @12:00 , @04/02/12 , @04/02/12 12:00 , @04/02/12 12:00 or just @04/02/12 . Heres my current code

Documentation for NSString sizeWithFont:forWidth:lineBreakMode: method (in the iPhone SDK)?

人盡茶涼 提交于 2020-01-03 03:57:41
问题 I can't find the documentation for the NSString sizeWithFont:forWidth:lineBreakMode: method (see Kevin Ballard's answer to "Sizing a UILabel (in the iPhone SDK) to fit?") in the NSString Class Reference in the iPhone SDK Developer Documentation. Where should I look? Update : I hadn't subscribed to an iPhone OS Library doc set, so my search didn't work. 回答1: In XCode, look for sizeWithFont:forWidth:lineBreakMode: . Make sure you have the iPhone docset selected/available. It's also here, if you

How to convert unicode hex number variable to character in NSString?

混江龙づ霸主 提交于 2020-01-03 03:52:04
问题 Now I have a range of unicode numbers, I want to show them in UILabel, I can show them if i hardcode them, but that's too slow, so I want to substitute them with a variable, and then change the variable and get the relevant character. For example, now I know the unicode is U+095F, I want to show the range of U+095F to U+096f in UILabel, I can do that with hardcode like NSString *str = [NSString stringWithFormat:@"\u095f"]; but I want to do that like NSInteger hex = 0x095f; [NSString

Escaping the @“ ” characters in Objective C

只愿长相守 提交于 2020-01-03 03:04:12
问题 I'm trying to set the background image of a view based on a passed "artistID." Here is my code so far: NSString *backgroundImageName = [[NSString alloc]initWithFormat:@"artistbackground%i.png",_artistID]; self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:backgroundImageName]]; NSLog(@"%@",backgroundImageName); unfortunately, for the parameter in ImageNamed, I'm passing in: artistibackground1 instead of: @"artistbackgound1" Any ideas on how to escape the @ and the

iOS编码规范参考

岁酱吖の 提交于 2020-01-03 01:29:39
目录 1 注释 1.1 多行注释 1.2 单行注释 1.3 函数的注释 2 命名 2.1 常量的命名 2.2 函数的命名 2.3 变量的命名 2.3.1 成员变量 2.3.2 公共变量命名 2.3.3 实例变量命名 2.4 图片的命名 2.5 类的命名 2.5.1 分类名 2.6 条件语句 2.7 变量 3 下划线 4 Immutable 实例初始化 5 类型 5.1 CGRect 函数 5.2 常量 5.3 枚举类型 5.4 布尔变量 5.5 单例 5.6 数字 6 代码组织 7 判断语句 8 私有方法 9 git commit 格式 9.1 参考规范 9.2 格式 10 函数声明和定义 11 方法调用 12 协议 13 Blocks iOS 编码规范参考 1 注释 建议使用 VVDocumenter 插件 1.1 多行注释 格式 : /** 注释内容 */ 1.2 单行注释 格式 : /// 在对文件、类、函数进行注释时推荐使用多行注释,在函数体内对代码块进行注释时,使用单行注释 1.3 函数的注释 函数注释的格式为 /** * @brief * @param * @return **/ 在 brief 中需要写明函数的主要功能、注意事项 在 param 中需要写明函数的变量类型、变量的作用 在 return 中需要写明函数的返回类型、返回值的作用 如有其他需要说明的地方

Recognize special characters in NSString

我与影子孤独终老i 提交于 2020-01-02 20:03:08
问题 I have a UITextView with text: 🅰🅱🍉👌📧🎏❡ its image: ( This is screen shot of my text, I worry somebody can not see my special character ) If I am an end-user , I just see that there are only 7 characters on textView. But [textView.text length] = 13 I want to split this text into an array like this: array = @[ , , ,... ] But I can't detect where is, where is, where is ... :( Could you help me! 回答1: Characters outside of the "basic multilingual plane" - in other words, characters whose Unicode

Weird behaviour of boundingRectWithSize:options:attributes:context:

本小妞迷上赌 提交于 2020-01-02 19:12:06
问题 I am experiencing a strange issue related to boundingRectWithSize:options:attributes:context: This is the code NSString *text = @"These long strings work"; CGSize maxSize = CGSizeMake(176.0f, MAXFLOAT); CGRect rect = [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:16.0]} context:nil]; CGSize size = rect.size; I have an xcode iOS project which uses this code. When I run the project, the size is (width

Leak or Crash - difference between autorelease and release

核能气质少年 提交于 2020-01-02 11:27:13
问题 I have a comprehension question. This method is given: - (NSArray*)test { NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://stackoverflow.com/"]]; NSString *result = [[NSString alloc] initWithBytes:[data bytes] length:[data length] encoding:NSMacOSRomanStringEncoding]; result = [result stringByAppendingString:@"something"]; NSArray *arr = [NSArray arrayWithObject:result]; //[result release]; return arr; } If I uncomment the release the App would crash and say it

Unsigned Char Array to Hex Representation NSString

泪湿孤枕 提交于 2020-01-02 07:39:28
问题 I have an unsigned char array and I want to convert it to hex NSString, currently I do it in the following way: unsigned char result[16]; // Fill the array NSString *myHexString = [NSString stringWithFormat: @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7], result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15] ]]; Is there a better way to built-in

[iPhone-APP]手机归属地查询软件

青春壹個敷衍的年華 提交于 2020-01-02 05:35:42
无聊。周末写几个APP玩,终于在上午把网络折腾好了。5块钱的8139网卡让我时常能在MAC下上网。 图标简陋啊。。。 技术要点: 1。组一个SOAP包。用NLURLConnection连接。 2。找一个webservice。 http://webservice.webxml.com.cn 3。解析XML。 4。显示,拖拽控件。 随便贴点组SOAP包头,发送的Code NSString * soapMessage = [NSString stringWithFormat: @" <?xml version=\ " 1.0 \ " encoding=\ " utf - 8 \ " ?>\n " " <soap:Envelope xmlns:xsi=\ " http: // www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\" http://www.w3.org/2001/XMLSchema \" xmlns:soap=\" http://schemas.xmlsoap.org/soap/envelope/ \">\n" " <soap:Body>\n " " <getMobileCodeInfo xmlns=\ " http: // WebXml.com.cn/\">\n" " <mobileCode>%@</mobileCode>\n "