nsstring

How to generate UUID in ios

匿名 (未验证) 提交于 2019-12-03 02:27:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How to get a UUID in objective c, like in Java UUID is used to generate unique random numbers which represents 128 bit value. 回答1: Try: CFUUIDRef udid = CFUUIDCreate(NULL); NSString *udidString = (NSString *) CFUUIDCreateString(NULL, udid); UPDATE: As of iOS 6, there is an easier way to generate UUID . And as usual, there are multiple ways to do it: Create a UUID string: NSString *uuid = [[NSUUID UUID] UUIDString]; Create a UUID: [[NSUUID UUID]; // which is same as.. [[NSUUID] alloc] init]; Creates an object of type NSConcreteUUID and can be

Change a UILabels text with a UISliders value

匿名 (未验证) 提交于 2019-12-03 02:27:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Hey guys i was wondering how i could show a UISliders value as a UILabels text. Thanks 回答1: Add an action to the slider, like this: [slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged]; Where the sliderChanged: method looks something like this: - (void)sliderChanged:(UISlider *)slider { self.label.text = [NSString stringWithFormat:@"%g", slider.value]; } 回答2: Try this: - (IBAction) sliderValueChanged:(UISlider *)sender { label.text = [NSString stringWithFormat:@"%f", slider.value]; } If label

'-[__NSDictionaryI length]: unrecognized selector sent to instance' - trying to figure out why

匿名 (未验证) 提交于 2019-12-03 02:27:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've a UITableView with custom UILabel for title and one another to subtitle, in order to align the text to right. My data come from web service, which I parse and store in NSArray of NSDictionary . Some of the title or the subtitle can be nil/empty-text. For this I'm putting it in try/catch. One of the lines in my table making my app crush and I cannot figure out why. I think one of them (title/subtitle) return as NSDictionary but I made a log print for class for my objects, for my [UILabel text] , seems like everything is ok. Exception and

How to solve this EXC_BAD_ACCESS(code=EXC_i386_GPFLT )in swift programming

匿名 (未验证) 提交于 2019-12-03 02:26:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: this is my code.getting this EXC_BAD_ACCESS(code=EXC_i386_GPFLT).I don'n know how to find and solve plz help me ...application getting crash when get longitude mapServerRequest="Hyderabad,india" var mapAddress:NSString=mapServerRequest mapAddress.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLPathAllowedCharacterSet()) println(mapAddress) var urlpath=NSString(format: "http://maps.googleapis.com/maps/api/geocode/json?address=%@", mapAddress) println(urlpath) var url = NSURL.URLWithString(urlpath) println(url) var

NSString boundingRectWithSize returning unnecessarily tall height

不羁的心 提交于 2019-12-03 02:25:53
问题 When using [NSString boundingRectWithSize:options:attributes] the size of the rect that is returned is taller than I would expect for certain strings. The height returned appears to represent the maximum possible height of a string with the given attributes, rather than the height of the string itself. Assuming the same attributes and options, the height returned for the string " cars " is the same height returned for the string " ÉTAS-UNIS " (note the accent on the E). I would have expected

How to display a base64 image within a UIImageView?

匿名 (未验证) 提交于 2019-12-03 02:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I got this Base64 gif image: R0lGODlhDAAMALMBAP8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAACH5BAUKAAEALAAAAAAMAAwAQAQZMMhJK7iY4p3nlZ8XgmNlnibXdVqolmhcRQA7 Now I want to display this Base64 String within my IPhone App. I could get this working by using the WebView: aUIWebView.scalesPageToFit = NO; aUIWebView.opaque = NO; aUIWebView.backgroundColor = [UIColor clearColor]; [aUIWebView loadHTMLString: @" " baseURL:nil]; Is it possible to do the same thing by using the UIImageView? 回答1: You don't have to encode it. Simply make

NSString to NSDate for yyyy-MM-dd'T'HH:mm:ss.SSS+05:30 format

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My date string that I am getting is 2014-01-08T21:21:22.737+05:30 of this format. How do i confer it to NSDate? I tried: NSString *currentDateString = @"2014-01-08T21:21:22.737+05:30"; [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS+05:30"]; NSDate *currentDate = [dateFormatter dateFromString:currentDateString]; NSLog(@"CurrentDate:%@", currentDate); It returns nil. Any thoughts? 回答1: Use this code it is working fine your dateFormatter was wrong . NSDateFormatter *dateFormatter=[[NSDateFormatter alloc]init]; NSString

Animate AVPlayerLayer videoGravity property

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to copy Apple's behavior in video playback that allows the user to stretch the video image to fill the bounds. @interface FHVideoPlayerView : UIView @end @interface FHVideoPlayerView + (Class)layerClass { return [AVPlayerLayer class]; } - (void)setAspectMode:(FHVideoPlayerAspectMode)aspectMode animated:(BOOL)animated { FHVideoPlayerAspectMode current = [self aspectMode]; FHVideoPlayerAspectMode final = aspectMode; NSString *fromValue; NSString *toValue; AVPlayerLayer *layer = (AVPlayerLayer *)[self layer]; switch (current) { case

Store images in to sqlite database

匿名 (未验证) 提交于 2019-12-03 02:15:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I know this question was asked by many people and there are several discussions and arguments on "Why to use sqlite,use FMDB,core data" etc.. to store or insert images in database.But please do understand my problem that I am very much used to sqlite3 and I am unable to go with core data or some other db.Also I am just in learning stages of iphone technology.So I request to please provide me a solution that can be dealt with sqlite only ;) Apologies if any wrong in my request! I have a text field that will show table with

Case-insensitive NSString comparison

橙三吉。 提交于 2019-12-03 02:13:30
Using this code I am able to compare string values. [elementName isEqualToString: @"Response"] But this compares case-sensitively. Is there a way to compare the string without case sensitivity? There’s a caseInsensitiveCompare: method on NSString , why don’t you read the documentation ? The method returns NSComparisonResult : enum { NSOrderedAscending = -1, NSOrderedSame, NSOrderedDescending }; typedef NSInteger NSComparisonResult; …ah, sorry, just now I realized you are asking for case sensitive equality. (Why don’t I read the question? :-) The default isEqual: or isEqualToString: equality