nsstring

issue in encoding a string with percent escaping iphone

旧巷老猫 提交于 2019-12-23 06:29:16
问题 This is my string. NSString *str=@"A & B"; now i am converting it to NSUTF8StringEncoding. str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSLog(@"str: %@", str); space is replaced with %20 but & is not replaced with %26. nslog show str: A%20&%20B This is also not working NSString *str=@"(A) & (B)"; str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSLog(@"str: %@", str); nslog show str: (A)%20&%20(B) I need this because i have to pass

Selection of text in core text like ibook

人走茶凉 提交于 2019-12-23 06:05:30
问题 i done a bible application which uses core text for showing verses in a view...the txt came from locally stored sqlite db,,,i am using this core text wrapper for rendering my text,,,becz it support multi column view ,,core text warpper,,,but i need the selection of verse functionality...if the user tap the verse it need to select that particular verse,,if i have this verse 1 The God create Heave and earth . 2 etc etc,,, . 3 etc etc,,,, . when the user tap the first verse it need to select

How do I change object's value (passed as a parameter) inside block

梦想的初衷 提交于 2019-12-23 05:42:33
问题 I have an POST request block in one of my functions and I want to change the value of an NSString object inside the block. I realise that normally one could just prefix the variable __block , but in my case, want to change the value of an NSString object by directly referencing its parameter. Here's a code skeleton, with relevant comments. - (void)getItemInformation:(NSString *)inputString{ //setup stuff [manager POST:@"http://foo.com/iphone_item_string/" parameters:parameters success:^

Why doesn't NSString getCharacters work in xcode?

本小妞迷上赌 提交于 2019-12-23 05:42:15
问题 -(void)myFunction { unichar myBuffer[5]; NSRange range = {0, 3}; NSString *string = [NSString alloc]; string = @"123"; [string getCharacters:myBuffer :range]; } Gets warning ! NSString may not respond to '-getCharacters::' then does a SIGABRT when I run it. Why????? Or better yet how can I get it to work? 回答1: To use getCharacters:range: , write this line of code: [string getCharacters:myBuffer range:range]; In Objective-C, method names are split up by arguments (a feature that derives from

addSkipBackupAttributeToItemAtURL -> NSString parameter?

杀马特。学长 韩版系。学妹 提交于 2019-12-23 05:17:21
问题 In order to follow the Data Storage Guidelines I must use the below method to add a flag to say to not back it up to iCloud. However, the parameter here is for a NSURL. I need to pass it a NSString like from a line like so return [[self offlineQueuePath] stringByAppendingPathComponent:@"SHKOfflineQueue.plist"]; Here is the method that takes in a URL. - (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL { if (&NSURLIsExcludedFromBackupKey == nil) { // iOS <= 5.0.1 const char* filePath = [

关于集成科大讯飞语音识别

谁都会走 提交于 2019-12-23 04:53:14
一、添加静态库 ⚠️将开发工具包中lib目录下地iflyMSC.framework添加到工程中去。 再添加如下图所示的库: 二、导入头文件 1 #import <iflyMSC/IFlyRecognizerViewDelegate.h> 2 #import <iflyMSC/IFlyRecognizerView.h> 3 4 #import <iflyMSC/IFlySpeechRecognizerDelegate.h> 5 #import <iflyMSC/IFlySpeechRecognizer.h> 6 7 #import <iflyMSC/IFlySpeechUnderstander.h> 8 9 #import <iflyMSC/IFlySpeechSynthesizerDelegate.h> 10 #import <iflyMSC/IFlySpeechSynthesizer.h> 11 12 #import <iflyMSC/IFlyContact.h> 13 #import <iflyMSC/IFlyDataUploader.h> 14 #import <iflyMSC/IFlyUserWords.h> 15 #import <iflyMSC/IFlySpeechConstant.h> 16 #import <iflyMSC/IFlySpeechUtility.h>

Different NSString results from URL download

纵饮孤独 提交于 2019-12-23 04:21:10
问题 I am parsing a string that I obtain from a website but get different results depending on how I download. This way it works: NSString *tagiString = @"http://tagesanzeiger.ch"; NSURL *tagiURL = [NSURL URLWithString:tagiString]; NSError *error; NSString *text =[NSString stringWithContentsOfURL:tagiURL encoding:NSASCIIStringEncoding error:&error]; Te following way it does not work. I first download the data, feed it into the NSMutableData *articleData and then convert to a NSString with

How do I detect a HTTP response, parse the xml and save to a NSString?

邮差的信 提交于 2019-12-23 02:56:08
问题 I've been trying to figure this out for weeks and i still get nothing. I am using the ASIHTTPRequest and ive successfully sent the data to a server and now I need to get the response XML,parse it and save the elements to each labeled NSString so I can post it to the server. Does anyone have an idea on how to do this? 回答1: From looking at the How to Use page, I think what you want to do is implement methods that can be called when the request is complete. For example, say you have a method

NSString stringWithFormat less parameters [duplicate]

随声附和 提交于 2019-12-23 01:42:08
问题 This question already has an answer here : Multiple arguments in stringWithFormat: “n$” positional specifiers (1 answer) Closed 3 years ago . We need to format a string, but for some localisations we won't output all parameters. But it seems that it doesn't work to output less parameters than passed: NSString *string = [NSString stringWithFormat: @"%2$@", @"<1111>", @"<22222>"]; NSLog(@"String = %@", string); Outputs String = <1111> although i output the second parameter. Is this a bug or a

Base64 issue in NSMutableURLRequest POST message?

余生颓废 提交于 2019-12-22 20:01:10
问题 I'm having communcation issues between my app and the server. I'm using RNCryptor to encrypt a message, which I then base64 encode and transfer to the server in the request. This is done in both the DATA header, and within the http body as post data. I think I'm making a mistake in how I'm converting & transferring the base64 encoded message via POST. If I receive the encrypted message via the header, it decrypts perfectly fine, every single time. However, if I take the message via the POST