我使用%s作为_cmd,最新的XCode将生成错误"Format指定类型char*但参数类型为SEL".检查文档,找不到线索.有人知道使用正确的字符串说明符吗?
有没有办法从一个持续时间显示一个小时的数字?例如,我有一个NSTimeInterval值包含127,我想显示02:07.
有什么更好的方法呢?谢谢.
我使用NSString stringWithFormat方法创建一个URL字符串.但是现在我有一个"快速"编辑这个字符串的问题.
例如,我在服务器上有一个脚本,用于处理带参数的请求.
我有一个像这样的URL字符串:
http://www.domain.com/api/?param1=%@¶m2=%@¶m3=%@¶m4=%@¶m5=%@&
Run Code Online (Sandbox Code Playgroud)
但是当我有超过5个,6个参数时,很难修改这个字符串.
任何人都知道如何创建URL字符串的最佳方法(我的意思是当我们修改它时).
Edit1: rob mayoff'answer很精彩.这是我自己的:
-(NSData *)change:(NSString *)hexString
{
int j=0;
Byte bytes[[hexString length]];
for(int i=0;i<[hexString length];i++)
{
int int_ch;
unichar hex_char1 = [hexString characterAtIndex:i];
int int_ch1;
if(hex_char1 >= '0' && hex_char1 <='9')
int_ch1 = (hex_char1-48)*16;
else if(hex_char1 >= 'A' && hex_char1 <='F')
int_ch1 = (hex_char1-55)*16;
else
int_ch1 = (hex_char1-87)*16;
i++;
unichar hex_char2 = [hexString characterAtIndex:i];
int int_ch2;
if(hex_char2 >= '0' && hex_char2 <='9')
int_ch2 = (hex_char2-48);
else if(hex_char1 >= 'A' && hex_char1 <='F')
int_ch2 = hex_char2-55;
else
int_ch2 = hex_char2-87;
int_ch …Run Code Online (Sandbox Code Playgroud) 我有一个UISearchBar,如果用户输入英文,我希望我的数据按pinYin排序,当用户输入中文字符时,我希望按字符本身排序.
有没有类似的东西
if (searchText isKindofClass: UTF-8String)
Run Code Online (Sandbox Code Playgroud)
检测是否NSString包含中文字符?
我正在学习Objective-C.你能告诉我这些NSString声明之间有什么区别(如果有的话)吗?
NSString *firstString;
firstString = @"First string";
NSString *secondString = [NSString string];
secondString = @"Second string";
Run Code Online (Sandbox Code Playgroud) 我想读取放在服务器上的文本文件.例如我的文件放在这个链接上:http://mysite.com/files/objects.txt
如何将这个文件的内容读入NSString?
我想自定义"无结果"字符串UISearchDisplayController.在文档中,您可以找到UISearchDisplayController具有searchResultsTitle我认为应该更改此字符串的属性,但它不起作用.
请帮助在iOS 5及更高版本中自定义"无结果"字符串.为什么searchResultsTitle不起作用?
uitableview nsstring uiviewcontroller uisearchbar uisearchdisplaycontroller
我无法使用字符串值保存数组中的选定项.知道什么是错的吗?
它是我的比较代码:
if(self.detailItem){
[WebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:[self.detailItem description] ofType:@"html"]isDirectory:NO]]];
NSString *value = (NSString *)self.detailItem;
NSString *value1 = (NSString *)@"DecideVectorVPiramidi";
value=[NSString stringWithFormat:@"%@", value];
value1=[NSString stringWithFormat:@"%@", value1];
if (value == value1) {
WebView.scalesPageToFit=YES;
}
Run Code Online (Sandbox Code Playgroud)
这是数组代码:
case 1:
switch (self.nomberInSection) {
case 0:
self.detailViewController.detailItem =[NSString stringWithFormat:@"%@", [DecideOfZakusPath objectAtIndex:indexPath.row]];
break;
}
break;
Run Code Online (Sandbox Code Playgroud)
类型detailItem是id.
对于错误,我查了一下
当我做:
NSString x = @"test"
Run Code Online (Sandbox Code Playgroud)
如何编辑它以使其成为"测试"?
当我把:
NSMutableString x = [[NSMutableString alloc] initWithString:@"test"];
Run Code Online (Sandbox Code Playgroud)
有一个错误说:
Initializer元素不是编译时常量.
谢谢
nsstring ×10
ios ×5
objective-c ×5
iphone ×2
c ×1
cmd ×1
cocoa ×1
compare ×1
nsdata ×1
nsurl ×1
specifier ×1
uisearchbar ×1
uitableview ×1
xcode ×1