nsstring

“-[CFString respondsToSelector:]: message sent to deallocated instance” when trying to access objectArray

匿名 (未验证) 提交于 2019-12-03 10:10:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to load next 10 rows of data in tableView when program fetches the last row in - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath I am using single function with pagenumber parameter to load the consecutive pages. It works for first fetch i.e. pagenumber 0, but when I call it again to fetch next page rows, it gives me this error -[CFString respondsToSelector:]: message sent to deallocated instance After banging my head for a long time, I've found that it creates this problem

iPhone app crash at [NSString stringWithFormat]

匿名 (未验证) 提交于 2019-12-03 10:03:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Hi I am getting the fowling error can any one help he in solving the issue. when I am sending the query to server the app is crashing before sending the query to server. > " (lldb) bt > * thread #1: tid = 0x2503, 0x38a4f5d0 libobjc.A.dylib`objc_msgSend + 16, stop reason = EXC_BAD_ACCESS (code=1, address=0x70706118) > frame #0: 0x38a4f5d0 libobjc.A.dylib`objc_msgSend + 16 > frame #1: 0x323169f0 Foundation`_NSDescriptionWithLocaleFunc + 52 > frame #2: 0x399dc430 CoreFoundation`__CFStringAppendFormatCore + 11160 > frame #3: 0x399538a2

Posting JSON data to server

匿名 (未验证) 提交于 2019-12-03 09:52:54
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to post and JSON data to server. My JSON is: { “username”:”sample”, “password” : “password-1” } The way I am sending it to server is: NSError *error; NSString *data = [NSString stringWithFormat:@"{\"username\":\"%@\",\"password\":\"%@\"}",_textFieldUserName.text,_textFieldPasssword.text]; NSData *postData = [data dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSData *jsonData = [NSJSONSerialization JSONObjectWithData:postData options:0 error:&error]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc]

timeout stringwithcontentsofurl

你离开我真会死。 提交于 2019-12-03 09:38:37
问题 I have this call to stringwithcontentsofurl: [NSString stringWithContentsOfURL:url usedEncoding:nil error:nil]; How can I give that a simple timeout? I don't want to use threads or operation queues (the content of the url is about 100 characters), I just don't want to wait too long when the connection is slow. 回答1: In this case, you might be best off using the NSURLConnection class method +sendSynchronousRequest:returningResponse:error: ; it'll return a data object you can initialize your

iPhone: find one string in another with case insensetive

淺唱寂寞╮ 提交于 2019-12-03 09:29:20
My question is similar to How do I check if a string contains another string in Objective-C? How can I check if a string (NSString) contains another smaller string but with ignoring case? NSString *string = @"hello bla bla"; I was hoping for something like: NSLog(@"%d",[string containsSubstring:@"BLA"]); Anyway is there any way to find if a string contains another string with ignore case ? But please do not convert both strings to UpperCase or to LowerCase. As similar to the answer provided in the link, but use options . See - (NSRange)rangeOfString:(NSString *)aString options:

Create csv file from array of data in iOS

匿名 (未验证) 提交于 2019-12-03 09:13:36
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I want to write data from sql file to csv file. I have collected all data from sql file in an array and using for loop i am appending and writing data to .csv file. but it seems that it shows data in one line only it does not go to new line to create new row. I have used this for reference. This is my code : -( NSString *) dataFilePath { NSArray * paths = NSSearchPathForDirectoriesInDomains ( NSDocumentDirectory , NSUserDomainMask , YES ); NSString * documentsDirectory = [ paths objectAtIndex : 0 ]; return [ documentsDirectory

How To get Image URL From PHAsset? Is it possible To save Image using PHAsset URL to document Directory?

匿名 (未验证) 提交于 2019-12-03 09:13:36
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I used `NSURL *urlA = [info valueForKey:@"PHImageFileURLKey"];` but when i try to save image using URL then URL is nil. `NSData *pngData =[NSData dataWithContentsOfURL:urlA options:NSDataReadingMapped error:nil];` 回答1: asset = Here you have to pass your PHAsset . PHImageRequestOptions * imageRequestOptions = [[PHImageRequestOptions alloc] init]; [[PHImageManager defaultManager] requestImageDataForAsset:asset options:imageRequestOptions resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {

Error in getting data from the server

匿名 (未验证) 提交于 2019-12-03 09:06:55
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am sending some data to my server using POST method. Code is as follows: NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"<myServer ip>"]]; [request setValue:@"application/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [request setHTTPMethod:@"POST"]; NSString *stringData = @"Hello"; NSData *requestBodyData = [stringData dataUsingEncoding:NSUTF8StringEncoding]; request.HTTPBody = requestBodyData; NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [conn

CocoaLumberjack iOS - Can we change the logfile name and directory?

匿名 (未验证) 提交于 2019-12-03 08:57:35
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am using CocoaLumberjack in my project. I need to change the name of the logfile to my custom file name. NSString * applicationDocumentsDirectory = [[[[ NSFileManager defaultManager ] URLsForDirectory : NSDocumentDirectory inDomains : NSUserDomainMask ] lastObject ] path ]; DDLogFileManagerDefault * documentsFileManager = [[ DDLogFileManagerDefault alloc ] initWithLogsDirectory : applicationDocumentsDirectory ]; DDFileLogger * fileLogger = [[ DDFileLogger alloc ] initWithLogFileManager : documentsFileManager ]; // Configure File

Quick way to jumble the order of an NSString?

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Does anyone know of an existing way to change the order of an existing NSString or NSMutableString's characters? I have a workaround in mind anyway but it would be great if there was an existing method for it. For example, given the string @"HORSE", a method which would return @"ORSEH", @"SORHE", @"ROHES", etc? 回答1: Consider this code: .h File: @interface NSString (Scrambling) + (NSString *)scrambleString:(NSString *)toScramble; @end .m File: @implementation NSString (Scrambling) + (NSString *)scrambleString:(NSString *)toScramble { for (int