nsstring

#define vs const and linking against frameworks

[亡魂溺海] 提交于 2020-01-07 06:15:03
问题 I have a really small lightweight application which needs to use some constants that are stored in a larger framework. I don't want to duplicate these constants and hardcode them into the lightweight application but I also don't want to have to link against the large framework to just get the constants. The constants are defined using static NSString *const in a header file. Does replacing the static NSString *const with #define prevent me from having to link against the whole framework ? To

iOS沙盒以及基于文件的持久化

最后都变了- 提交于 2020-01-07 04:25:21
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 新建一个demo项目 在 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 方法中调用如下代码 NSArray *documentDirectories = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); NSString *documentDirectory = [documentDirectories firstObject]; NSLog(@"documentDirectory = %@",documentDirectory); 输出的路径,在finder中可以前往文件夹打开 可以看到如下的目录结构 Documents 目录是保存数据,备份或者同步也是这个目录 Library/Caches app产生的数据会保存在这里,用来记住每次运行的数据,但是不会被同步 Library/Preferences NSUserDefault类操作的数据 temp/ 不会备份,但是不需要的时候还是能清处理,NSTemporaryDirectory

Using a variable as a key for a PFQuery to filter out users. Swift Querying a User

╄→尐↘猪︶ㄣ 提交于 2020-01-07 03:10:08
问题 Variable in a User class as a string. Using this variable as a key for a PFQuery and use it to filter out the users that don't have it.I need to skip users that don't have it and add the users that do to the VC display. Here is my code so far: In the VC where the variable is stored I have: var genreSearch: NSString? after viewDidLoad in a cell I have: let genreSearch = table_data[indexPath.row] userDefaults.setObject(genreSearch, forKey: "genre") print(genreSearch)` Then on the VC where the

How to display accented characters using NSMutableAttributedString?

爷,独闯天下 提交于 2020-01-07 02:49:28
问题 In my NSString , I've some accented characters and html tags, such as <i></i> . I want to display them in NSTextField with text attributes to them. When I build the attrStr, I use: NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithHTML:[text dataUsingEncoding:NSUTF8StringEncoding] options:@{NSWebPreferencesDocumentOption : webPreferences} documentAttributes:NULL]; I display the text as follow: someTextField.attributedStringValue = attrStr; But this require I know

Rotating a NSString in drawRect

半腔热情 提交于 2020-01-07 01:59:56
问题 I want to rotate my NSString that's at a set location so that it reads from bottom to up. I know the issue lies in the CGContextTranslateCTM, but I'm not sure how to fix it. If I comment this line, I see my text where I want it, just not rotated. This must be moving my NSString to where it is not visible. Thoughts? Here's what I have tried: NSString * xString = [NSString stringWithFormat:@"%@", self.xStringValue]; CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(), [[UIColor

Rotating a NSString in drawRect

可紊 提交于 2020-01-07 01:59:27
问题 I want to rotate my NSString that's at a set location so that it reads from bottom to up. I know the issue lies in the CGContextTranslateCTM, but I'm not sure how to fix it. If I comment this line, I see my text where I want it, just not rotated. This must be moving my NSString to where it is not visible. Thoughts? Here's what I have tried: NSString * xString = [NSString stringWithFormat:@"%@", self.xStringValue]; CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(), [[UIColor

objective c: passing a char argument to function crashes the app

半城伤御伤魂 提交于 2020-01-06 19:29:30
问题 I wrote a singleton called SomeValues where I initialize a foo NSMutableArray. I then tried to write a function SetBFSV to set the values of this array from different control views. @interface SomeValues : NSObject { NSMutableArray *foo;} + (SomeValues *) sharedInstance; @implementation ... - (void) SetBFSV:(char)lbl ToVal:(long)BFSvl{ NSNumber *ValueBFSvl = [NSNumber numberWithLong:BFSvl]; NSString *Strlbl = [[NSString alloc] stringWithFormat:@"%s",lbl]; [foo setValue:ValueBFSvl forKey

Is it possible to bold an NSString?

流过昼夜 提交于 2020-01-06 17:59:24
问题 Is it possible to make an NSString bold? If so, how? I am not using UILabel or UIIextView for some reason. 回答1: NSStrings hold strings and no text formatting. I assume you could render an NSString using webkit; in that case the NSString will hold html content... 来源: https://stackoverflow.com/questions/3829469/is-it-possible-to-bold-an-nsstring

Is it possible to bold an NSString?

社会主义新天地 提交于 2020-01-06 17:59:10
问题 Is it possible to make an NSString bold? If so, how? I am not using UILabel or UIIextView for some reason. 回答1: NSStrings hold strings and no text formatting. I assume you could render an NSString using webkit; in that case the NSString will hold html content... 来源: https://stackoverflow.com/questions/3829469/is-it-possible-to-bold-an-nsstring

How to make this UILabel move the email address to the next Line?

痞子三分冷 提交于 2020-01-06 14:51:31
问题 I have a simple UILabel that is printing text as follows: John Doe sent a message to blahblah- blah@blahblah.com Thus, the email address here : blahblah-blah@blahblah.com is being cut and partially displayed on the next line. What do I need to do to make it display as : John Doe sent a message to blahblah-blah@blahblah.com ? I already have the following : self.mailLabel.lineBreakMode = NSLineBreakModeByWordWrapping; self.mailLabel.numberOfLines = 0; The string in question is : [NSString