我有一个NSDictionary对象,由NSMutableStrings填充其键和对象.我已经能够通过使用setString:方法更改原始NSMutableString来更改密钥.然而,无论最初用于设置密钥的字符串的内容如何,它们的密钥都保持不变.
我的问题是,密钥是否受到保护而不被更改意味着除非我将其删除并将另一个添加到字典中,否则它将始终相同?
谢谢.
我想向google地方发送请求(不是谷歌地方API),我不需要获取XML或JSON数据,我只想获取地点页面并将其显示给用户.
这个网址对我有用http://maps.google.com/maps/place?cid=2124238351431937390,但我想知道如何获得这个"cid",这似乎是一个独特的业务ID.我去了谷歌地方api的样本回复,但没有找到与任何响应字段相同的业务的这个cid.
有谁知道我怎么能得到这个"cid"?
谢谢Nishant
我在Android 2.1中工作,我想检测耳机插入/取出的时间.我对android很新.
我认为这样做的方法是使用广播接收器.我放弃了这个,我还在AndroidManifest.xml中添加了以下内容.但你是否必须在其他方面注册接收器,就像在活动中一样?我知道这有很多线索,但我真的不明白他们在谈论什么.另外,在AndroidManifest.xml中注册与在活动中动态注册之间的区别是什么?
<receiver android:enabled="true" android:name="AudioJackReceiver" >
<intent-filter>
<action android:name="android.intent.action.HEADSET_PLUG" >
</action>
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
这是该类的实现(加上进口)
public class AudioJackReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.w("DEBUG", "headset state received");
}
Run Code Online (Sandbox Code Playgroud)
}
我只是想看看它是否有效,但是当我在运行应用程序时拔下/插入耳机时没有任何显示.
编辑:文档没有说明这一点,但如果在清单中注册,这个可能无法正常工作吗?当我在我的一个应用程序中注册接收器时,我能够让它响应(或者你还必须这样做吗?)
我试图MPMediaQuery在iOS中从iPod库中检索播放列表.我想展示一下UITableView.
这是我的代码viewDidLoad.
MPMediaQuery *myQuery = [[MPMediaQuery alloc] init];
[myQuery setGroupingType: MPMediaGroupingPlaylist];
arrayOfPlaylist = [myQuery collections];
Run Code Online (Sandbox Code Playgroud)
在UITableViewCell方法中
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
for(int i=0;i<self.arrayOfPlaylist.count;i++)
{
dic = [self.arrayOfPlaylist objectAtIndex:0];
cell.textLabel.font = [UIFont systemFontOfSize:10];
cell.textLabel.text = [NSString stringWithFormat:@"%@",[self.arrayOfPlaylist objectAtIndex:indexPath.row]];
}
return cell;
Run Code Online (Sandbox Code Playgroud)
在我写完上面的代码之后,UITableView我只收到了以下消息:
<MPConcreteMediaPlaylist : 0x1e51afd0>
Run Code Online (Sandbox Code Playgroud)
我不知道那是什么以及如何将播放列表名称转换为字符串.当我用NSLog方法测试时,我的播放列表计数是正确的.
但是我只收到了上面的消息而没有播放列表名称UITableView.
我只是iOS的初学者.
请帮我显示播放列表UITableView …
我有一个BaseClassUIViewController 类。它运作良好。BaseClass有 BaseClass.xib
然后我创建了该基类的子类。
结果发现没有连接任何插座。
我放
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
return self;
}
Run Code Online (Sandbox Code Playgroud)
是的,它就在那里。它被称为。我不确定 aDecoder 是什么。我认为它是 childClass 的 XIB 的表示,它不存在。我想用 super 的 xib 初始化 super。
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
永远不会被调用。
事实上,我自己也很困惑。当我们有 xib 时,似乎就是那个 -(id)initWithCoder:(NSCoder *)aDecoder被调用的。所以我想知道 initWithNibName 是干什么用的?
我试过
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithNibName:NSStringFromClass([super class]) bundle:nil];
return self;
}
Run Code Online (Sandbox Code Playgroud) 使用http get request我确实得到了这个json字符串:
hello
[
{
"upid":"1",
"uptitle":"test",
"uptype":"test",
"upsize":"1234",
"upname":"test",
"upuid":"1",
"uplocation":"1",
"uptimestamp":"2013-04-11 09:25:40"
},
{
"upid":"17",
"uptitle":"test",
"uptype":"video\/mov",
"upsize":"2232",
"upname":"testing",
"upuid":"1",
"uplocation":"",
"uptimestamp":"2013-04-12 11:47:20"
}
]
Run Code Online (Sandbox Code Playgroud)
我如何以格式获得输出:
upid:1
uptitle:test
uptype:test
upsize:1234
upname:test
upuid:1
uplocation:1
uptimestamp:2013-04-11 09:25:40
upid:17
uptitle:test
uptype:video\/mov
upsize:2232
upname:testing
upuid:1
uplocation:
uptimestamp:2013-04-12 11:47:20
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
NSMutableURLRequest *GETrequest = [[NSMutableURLRequest alloc] init];
[GETrequest setURL:[NSURL URLWithString:@"http:someip/upload/?id=1&command=alluseruploads&uid=1"]];
[GETrequest setHTTPMethod:@"GET"];
[GETrequest setValue:@"application/json;charset=UTF-8" forHTTPHeaderField:@"Content-Type"];
// And to send and receive an answer, use a NSURLResponse:
NSURLResponse *response;
NSData *GETReply = [NSURLConnection sendSynchronousRequest:GETrequest …Run Code Online (Sandbox Code Playgroud) 使用NSDateFormatter解析日期.下面的日期是2013年5月2日.我得到不同的结果(如下所示)取决于我是否在dateFormat字符串中使用"DD"和"dd"
NSString * dateStr = @"2013-05-02";
NSDateFormatter * dateFormat = [NSDateFormatter new];
[dateFormat setDateFormat:@"yyyy-MM-DD"];
NSDate * date = [dateFormat dateFromString:dateStr];
NSLog(@"%@",[dateFormat stringFromDate:date]);
//logs 2013-01-02 ** incorrect
[dateFormat setDateFormat:@"yyyy-MM-dd"];
//logs 2013-05-02 ** correct
Run Code Online (Sandbox Code Playgroud)
什么是"DD"在做什么?它有什么用吗?
我一直在网上试图找到这些日期格式字符串的权威指南,我还没有找到.如果有人知道,请告诉我.
谢谢
我正在更改我的应用程序以支持3.5"显示.目前它支持4"显示器.屏幕布局如下所示.如何在故事板中添加以下约束?(我在故事板中启用了自动布局选项.)
如何将button1和button2宽度设置为超视图宽度的一半?两者都应该在超视图宽度的中间相交.
UIImage#1应放在superview宽度的中间位置.

我正在尝试在Xcode(下Targets->General->Identity)中更改iOS项目中的版本和内部版本号,但由于某些原因,无论我输入什么内容,我的输入都会被删除,值也不会改变.这不是修改此值的正确位置吗?
打算Targets->General->Info让我改变的价值,但不记得在更改后我浏览远离屏幕.
ios ×5
objective-c ×5
xcode ×2
android ×1
cocoa ×1
cocoa-touch ×1
date ×1
dictionary ×1
foundation ×1
google-api ×1
google-maps ×1
ios7 ×1
json ×1
nsdate ×1
uitableview ×1
version ×1
xcode4.5 ×1
xcode5 ×1