nsstring

How save images in home directory?

匿名 (未验证) 提交于 2019-12-03 01:26:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am making an application in which i have use Json parsing. With the help of json parsing i get photo url which is saved in string. To show images in my cell i use this code NSString * strURL =[ NSString stringWithFormat :@ "%@" , [ list_photo objectAtIndex : indexPath . row ]]; NSData * imageData = [[ NSData alloc ] initWithContentsOfURL : [ NSURL URLWithString : strURL ]]; CGRect myImage = CGRectMake ( 13 , 5 , 50 , 50 ); UIImageView * imageView = [[ UIImageView alloc ] initWithFrame : myImage ]; [ imageView setImage :[ UIImage

NSString get -characters

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to get the characters of an NSString. Like this: NSString *data; const char * typein = [[data characters] UTF8String]; But obviously NSString won't respond to -characters. How do I get the characters of NSString? thanks, Elijah 回答1: You can use this function: for(int i =0 ;i or NSString *str = @"astring"; const char *cString = [str UTF8String]; 回答2: If you just want to get a cString from the NSString just call UTF8String as you are already doing and then iterate the array. 文章来源: NSString get -characters

Issue with loading and caching retina images for UIImageView animation

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: What I have For my game I'm creating several animations using view.animationImages = imagesArray; [view startAnimating]; In my animation helper class I use this - (UIImage *)loadRetinaImageIfAvailable:(NSString *)path { NSString *retinaPath = [[path stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@@2x.%@", [[path lastPathComponent] stringByDeletingPathExtension], [path pathExtension]]]; if ([UIScreen mainScreen].scale == 2.0 && [[NSFileManager defaultManager] fileExistsAtPath:retinaPath] == YES

CFURLCreateStringByAddingPercentEscapes is deprecated in iOS 9, how do I use “stringByAddingPercentEncodingWithAllowedCharacters”

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have the following code: return (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, CFSTR(";:@&=+$,/?%#[]"), kCFStringEncodingUTF8); Xcode says it is deprecated in iOS 9. So, how do I use stringByAddingPercentEncodingWithAllowedCharacters ? Thanks! 回答1: try this NSString *value = @" "; value = [value stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; 回答2: The character set URLQueryAllowedCharacterSet contains all characters allowed in the query

How to check whether a string contains white spaces

久未见 提交于 2019-12-03 01:24:25
How to check whether a string contains whitespaces in between characters? use rangeOfCharactersFromSet: NSString *foo = @"HALLO WELT"; NSRange whiteSpaceRange = [foo rangeOfCharacterFromSet:[NSCharacterSet whitespaceCharacterSet]]; if (whiteSpaceRange.location != NSNotFound) { NSLog(@"Found whitespace"); } note: this will also find whitespace at the beginning or end of the string. If you don't want this trim the string first... NSString *trimmedString = [foo stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; NSRange whiteSpaceRange = [trimmedString

Ios: Remove audio from video

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have requirement some times mute video send enduser so I required remove audio file form the video. Passing video for single process for mute. 回答1: // Remove audio from video - (void) RemoveAudioFromVideo:(NSString *)VideoLocalPath { NSString * initPath1 = VideoLocalPath; AVMutableComposition *composition = [AVMutableComposition composition]; NSString *inputVideoPath = initPath1; AVURLAsset * sourceAsset = [[AVURLAsset alloc] initWithURL:[NSURL fileURLWithPath:inputVideoPath] options:nil]; AVMutableCompositionTrack *compositionVideoTrack =

POST multipart/form-data with Objective-C

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: So this HTML code submits the data in the correct format for me. Name: Email: Password: Avatar: I've looked into a good number of articles on how to do a multipart/form-data POST on iOS, but none really explain what to do if there were normal parameters as well as the file upload. Could you please help me with the code to POST this in Obj-C? Thanks! 回答1: The process is as follows: Create dictionary with the userName , userEmail , and userPassword parameters. NSDictionary *params = @{@"userName" : @"rob", @"userEmail" : @"rob@email.com", @

Get host name From IP address iOS 10

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to fetch host name from ip address . Am able to fetch ip, mac addresses of all devices connected to my devices network, but hostname always returns nil . i had tried below code snippets to retrieve hostname but it always returns nil in my network CODE SNIPPET 1 +(NSString *)getHostFromIPAddress:(NSString*)ipAddress { struct addrinfo *result = NULL; struct addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_NUMERICHOST; hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = 0; int

FFmpeg iOS -> output file is invalid

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using following library to convert mkv to mp4: https://github.com/SterlingOnLoop/FFmpegWrapper . - (void)convertUsingFFmpegWrapper { NSString *mp4Extension = @"mp4"; NSString *mkvExtension = @"mkv"; NSString *videoName = @"file1"; // NSString *videoName = @"file2"; NSString *mkvVideoFilePath = [[NSBundle mainBundle] pathForResource:videoName ofType:mkvExtension]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = paths[0]; NSString *mp4VideoFilePath = [NSString

Why does my app crash when backgrounding when using [NSAttributedString initWithData]

匿名 (未验证) 提交于 2019-12-03 01:17:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a viewController that manages a UICollectionView. I have a helper method that is called from cellForItemAtIndexPath that provides an NSAttributedString for a label in the cell. The helper method formats an NSAttributedString from an html string. The app will crash when moving to the background, but only if the indexPath.item is greater than 1. In other words, I can exit the app without crashing from the first or second cell, but crash consistently on the third, forth, ... cell. Here are my helper method and stack trace. Any idea why I