开发者

How do i use the return function, when it requires passing data?

I'm using this code:

http://imthi.com/blog/programming/iphone-sdk-convert-hex-color-string-to-uicolor.php

But i'm unsure as to how to get it to run 开发者_如何学Gothat code on my NSString from somewhere else.

How do i use return here?


Create two files

NSString+meltutils.h and NSString+meltutils.m

Put the content from the post into the respective files. Then in your program add this to the top of the file:

"#import “NSString+meltutils.h” // no quotes

Then somewhere in your program do this:

UIColor *aColorStr = [@"yourStringHere" toUIColor];


Look in the comments on that post.

He creates a category for NSString. This essentially adds methods to NSString (kinda like monkey patching in Ruby).

Once you do that, you can take an NSString that has a hexcolor string value and call toUIColor and receive a UIColor object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜