nsstring

NSURL is null while NSString is correct in Objective-C

旧街凉风 提交于 2019-12-23 10:20:21
问题 I have an NSString containing a url and when I allocate NSURL with the NSString , NSURL outputs (null). It's because there are some illegal characters in the url, which NSURL can't read without encoding the NSString containing the url. NSString *u = [incomingUrlString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSURL *url = [NSURL URLWithString:u]; NSLog(@"INCOMINGURLSTRING: %@" , u); NSLog(@"URL: %@" , url); Output is: INCOMINGURLSTRING: /url/path/fileName_blå.pdf URL

Adding double quotes to NSString

别说谁变了你拦得住时间么 提交于 2019-12-23 09:58:46
问题 I have reading everything and \" does NOT work. I am trying to create a string that looks like this: "SomeString" = "AnotherString" Here is the code that I have to insert the double quotes: NSString *newOutput = [NSString stringWithFormat:@"%@ \" = \" %@", output, [englishDic objectForKey:str]]; All that it outputs is: "RateThisAppDontAsk \" = \" Don't ask again" I thought maybe the "=" was causing problems but removing still gives me an output of this: "RateThisAppDontAsk \" \" Don't ask

extern NSString *const in a class.

人走茶凉 提交于 2019-12-23 09:41:52
问题 Hi I've got this header file: #import <Foundation/Foundation.h> @interface PCConstants : NSObject extern NSString *const kPCUserProfileKey; extern NSString *const kPCUserProfileNameKey; extern NSString *const kPCUserProfileFirstNameKey; extern NSString *const kPCUserProfileLocationKey; extern NSString *const kPCUserProfileGenderKey; extern NSString *const kPCUserProfileBirthDayKey; extern NSString *const kPCUserProfileInterestedInKey; @end implementation: #import "PCConstants.h"

extract substring from NSString [closed]

ぃ、小莉子 提交于 2019-12-23 09:15:09
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . I wants to extract substring from NSString. How it is possible. Example : String is abcdefwww.google.comabcdef output : www.google.com In the main String

Fade out end of text label strings that don't fit (instead of truncate)

走远了吗. 提交于 2019-12-23 09:01:49
问题 I'm not sure if "fade out" is the correct term to use, as it seems to refer to the animation effect a lot, but what I'd like to achieve can be seen in the address bar of the iPhone Safari app. When a URL is too long to display, the end of the string "faded out" rather than truncated with "...". I thought this could be easily done by changing the Line Breaks setting from "Truncate Tail" to "Clip" in the XIB file and then using an image with transparency to create the effect. But setting to

Split NSString by number of whitespaces

我怕爱的太早我们不能终老 提交于 2019-12-23 08:59:29
问题 I have an NSString that contains some values separated by an unknown number of whitespace characters. For example: NSString* line = @"1 2 3"; I would like to split the NSString into an NSArray of values like so: {@"1", @"2", @"3"} . 回答1: Get the components separated by @" " and remove all objects like @"" from the resultant array. NSString* line = @"1 2 3"; NSMutableArray *array = (NSMutableArray *)[line componentsSeparatedByString:@" "]; [array removeObject:@""]; // This removes all objects

Split NSString by number of whitespaces

限于喜欢 提交于 2019-12-23 08:59:18
问题 I have an NSString that contains some values separated by an unknown number of whitespace characters. For example: NSString* line = @"1 2 3"; I would like to split the NSString into an NSArray of values like so: {@"1", @"2", @"3"} . 回答1: Get the components separated by @" " and remove all objects like @"" from the resultant array. NSString* line = @"1 2 3"; NSMutableArray *array = (NSMutableArray *)[line componentsSeparatedByString:@" "]; [array removeObject:@""]; // This removes all objects

Replace “ ” character in an NSString with “\ ” (to create a Unix path)

久未见 提交于 2019-12-23 08:57:14
问题 Using the following doesn't work: - (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement By doesn't work I mean does not do any replacement what so ever. It returns the same exact string. Is there a convenience method to do this? Similar to: - (NSString *)stringByReplacingPercentEscapesUsingEncoding:(NSStringEncoding)encoding My code (just one line): NSString *escapedPath = [pathToBeConverted stringByReplacingOccurrencesOfString:@" "

How to URL encode a NSString

我是研究僧i 提交于 2019-12-23 08:56:41
问题 I am trying to url encode a string, but the NSURLConnection is failing because of a 'bad url'. Here is my URL: NSString *address = mp.streetAddress; NSString *encodedAddress = [address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *cityState= mp.cityState; NSString *encodedCityState = [cityState stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *fullAddressURL = [NSString stringWithFormat:@"http://www.zillow.com/webservice

How to obtain plain 'globe' Unicode character

元气小坏坏 提交于 2019-12-23 07:59:39
问题 If you include Unicode characters in an NSString , a lot of them will take on the color set for that text - they're just regular glyphs for that font so they're displayed like any other character. But there are some Unicode characters that are colored, for example GLOBE WITH MERIDIANS which is a blue gradient with shadows. But I have seen this same glyph elsewhere that's a simple black outline without a shadow, for example in the iOS keyboard. I would like to use that glyph, but without the