Sha256: c7e0ac3e84a3ea6fc39161bad84f8aa4df3b8f2c8d7ac092e7136725ec1cd2b5
Contents?: true
Size: 1.29 KB
Versions: 18
Compression:
Stored size: 1.29 KB
Contents
class NSString def nsurl @url ||= NSURL.alloc.initWithString(self) end def escape_url CFURLCreateStringByAddingPercentEscapes( nil, self, nil, "!*'();:@&=+$,/?%#[]", CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding) ) end def unescape_url CFURLCreateStringByReplacingPercentEscapes( nil, self, "" ) end def uiimage UIImage.imageNamed(self) end def uiimageview (self.uiimage and self.uiimage.uiimageview or UIImageView.alloc.initWithImage(nil)) end def uifont(size=UIFont.systemFontSize) @uifont ||= {} @uifont[size] ||= UIFont.fontWithName(self, size:size) end def uicolor(alpha=nil) if self[0,1] == '#' if self.length == 4 return (self[1] * 2 + self[2] * 2 + self[3] * 2).to_i(16).uicolor(alpha) end return self[1..-1].to_i(16).uicolor(alpha) end self.uiimage.uicolor(alpha) end # This can be called as `"Hello".localized` or `"Hello"._`. The `str._` # syntax is meant to be reminiscent of gettext-style `_(str)`. def localized(value=nil, table=nil) @localized = NSBundle.mainBundle.localizedStringForKey(self, value:value, table:table) end alias _ localized end
Version data entries
18 entries across 18 versions & 1 rubygems