nsstring

Objective C: Initializing NSString

折月煮酒 提交于 2019-12-12 00:19:37
问题 I have a simple block of code that needs to set an NSString as one thing or another. In it's most basic form, it looks like this: if (conditionMet){ NSString *outputString=[NSString stringWithString:@"A"]; } else { NSString *outputString=[NSString stringWithString:@"B"]; } return outputString; But, I'm getting a "Use of undeclared identifier 'outputString'" error. What is a better way to do this? I understand this is a pretty basic question, so any quick pointers on how to do this would be

24hr to 12hr time convert, insert character to string

醉酒当歌 提交于 2019-12-11 20:37:35
问题 This is sort of a secondary question to my question here but it was suggested split the questions up for a better response. I have individual lines of data like the following that a passed to the function separately. Mon-Wed 930-1700 Thu 900-1700 Fri 930-1700 Mon-Wed 930-1700 Thu 900-1700 Fri 930-1700 Sat 900-1200, Home Lending Sat 900-1600 Mon-Thu 900-1600, Fri 900-1700 And need it to read as follows for example: Mon-Wed 9:30am-5:00pm;Thu 9:00am-5:00pm;Fri 9:30am-5:00pm;Sat 9:00am-12:00pm,

NSMutableArray within NSString

那年仲夏 提交于 2019-12-11 20:35:05
问题 After 10 years without programming (in Delphi at the time), I began learning Objective-C. I confess I have met lots of problems as this approach is very different. I want to make a simple table in which each line consists of several NSString variables. An example: ID Firstname Lastname 01 FN1 LN1 02 FN2 LN2 My table: NSString * FirstName, * LastName; NSMutableArray * person = [NSMutableArray arrayWithObjects: firtsname, lastname, nil]; The problem is that I can not add a line with the 2

Why are all things in Objective-C created by * lower case?

折月煮酒 提交于 2019-12-11 19:57:13
问题 I'm really confused about this thing. In any tutorial, code on github and documentation I have seen BOOLs, NSStrings, NDDictionaries etc all start in lower case. Eg. NSString *aString Is this necessary? Will anything get ruined if I use upper-case while creating BOOLs etc? I'm really confused here :P Any help is greatly appreciated! Edit: Will using an underscore and then declaring variables in Capitals be a good idea? 回答1: Added from comments Its more of a coding standards thing. I have just

UITextview dataDetectorTypeAddress - Map opened in different application

别来无恙 提交于 2019-12-11 19:48:26
问题 I just came to know about an awesome ios feature for UITextViews i.e UITextview dataDetectorTypes. It is really useful to display text as links. However, I noticed one thing. When the string is a physical address, Google Map is opened which is appropriate, but in a different application. Is there any way we can open that google map in our application and not go into default iOS application wherein map is opened? So that I can go back into my application from the map. Is there any delegate

Converting NSString to array of chars inside For Loop

戏子无情 提交于 2019-12-11 18:56:47
问题 I'm trying to use an existing piece of code in an iOS project to alphabetize a list of words in an array (for instance, to make tomato into amoott, or stack into ackst). The code seems to work if I run it on its own, but I'm trying to integrate it into my existing app. Each word I want it to alphabetize is stored as an NSString inside an array. The issue seems to be that the code takes the word as an array of chars, and I can't get my NSStrings into that format. If I use string = [currentWord

how to remove a word from a string

泄露秘密 提交于 2019-12-11 18:49:30
问题 hello i am a beginner in objective-c i have a nsstring like this Select * from Store_Master where AND VDivison = 'Casual Dining' AND VBrand_Name = 'Pinkberry' AND VCountry_Name = 'Egypt' AND VCity = 'Cairo' AND VBuilding_mall_name = 'Dandy Mega Mall' GROUP BY VStore_Name i want to just remove first occurance of AND,how can i remove. Thank you in advance 回答1: Use stringByReplacingCharactersInRange to replace only the first 'AND': NSString* s = @"Select * from Store_Master where AND VDivison =

Objective C string manipulation, peeking, adding to

荒凉一梦 提交于 2019-12-11 18:34:11
问题 I am trying to manipulate a string of open hours that is given to me. It is poorly formatted and I need to bring it up to the same standard as another piece of data from a different source. Mon-Wed 930-1700 Thu 900-1700 Fri 930-1700 Mon - Wed 930-1700 Thu 900-1700 Fri 930-1700 Mon - Thu 930-1600 Fri 930-1700 Mon - Wed 930-1700 Thu 900-1700 Fri 930-1700 Sat 900-1200 As you can see there is not always spaces between hyphens on days etc. I need it to be separated by semicolon as follows: Mon-Wed

ios wkwebview js alert

北城余情 提交于 2019-12-11 17:58:12
1.将WKWebView的WKUIDelegate设置成self。 2.将一下三个方法拷贝到项目中。 解决alert方法 -(void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler{ UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:message?:@"" preferredStyle:UIAlertControllerStyleAlert]; [alertController addAction:([UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { completionHandler(); }])]; [self presentViewController

ios wkwebview js alert

僤鯓⒐⒋嵵緔 提交于 2019-12-11 17:57:59
1.将WKWebView的WKUIDelegate设置成self。 2.将一下三个方法拷贝到项目中。 解决alert方法 -(void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler{ UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:message?:@"" preferredStyle:UIAlertControllerStyleAlert]; [alertController addAction:([UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { completionHandler(); }])]; [self presentViewController