我有一个ArrayList我需要排序的东西,我还需要一个特定的默认项目在列表的顶部.我可以通过检查数组列表,删除默认项目并将其插入列表顶部来自行完成.
基本上,列表应该在顶部具有默认值,而剩余值在排序顺序中.是否有任何现有的API方法可以做到这一点?
我试图在Objective-C中实现以下目标:
curl -X POST -u "<application key>:<master secret>" \
-H "Content-Type: application/json" \
--data '{"aps": {"badge": 1, "alert": "The quick brown fox jumps over the lazy dog."}, "aliases": ["12345"]}' \
https://go.urbanairship.com/api/push/
Run Code Online (Sandbox Code Playgroud)
是否有某种我可以使用的库来实现这一目标?很明显,我已经准备好了所有的价值观并提出我的要求,但我不确定如何在Objective-C中做到这一点.
我正在使用TouchJSON,但是我不太确定如何在上面构造正确的JSON有效负载并将其POST到服务器(我更喜欢这是异步请求而不是同步).
NSError *theError = NULL;
NSArray *keys = [NSArray arrayWithObjects:@"aps", @"badge", @"alert", @"aliases", nil];
NSArray *objects = [NSArray arrayWithObjects:?, ?, ?, ?, nil];
NSDictionary *theRequestDictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
NSURL *theURL = [NSURL URLWithString:@"https://go.urbanairship.com/api/push/"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:theURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10.0f];
[theRequest setHTTPMethod:@"POST"];
[theRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSData *theBodyData …Run Code Online (Sandbox Code Playgroud) 你能使用静态库中定义的宏吗?
我有自己的调试宏TWDEBUG,我在一个我创建用于共享的静态库中使用.如果我将静态库导入到我的新项目并使用它,编译器似乎无法识别它.我确实将预处理器宏设置为TWDEBUGand Other C flags和Other C++ flagsto -TWDEBUG,但是当我运行代码时,ifdef宏不会被执行.
我想写一个基于Oracle的查询,我可以选择是否要查看结果.让我们说:
SELECT *
FROM table
//when there are more than 10 rows
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
我想用2创建一个程序JPanel使用BorderLayout.中间面板用于随机绘制矩形,而南面板用于按钮.
JFrame每当我将鼠标光标悬停在北或南按钮上时,我就会看到左上角按钮的奇怪图像.我做了一些研究,发现这可能是拥有透明背景的原因.我尝试使用super.paintComponent(g)面板,但之前绘制的其余矩形消失了.我需要将矩形留在JPanel左上角而不是奇怪的图像中.
我不知道我做错了什么,希望有人可以帮助或提供一些如何解决这个问题的线索.
public class TwoBRandomRec extends JFrame{
private static final long serialVersionUID = 1L;
public static void main(String[] args) {
TwoBRandomRec rec = new TwoBRandomRec();
rec.setSize(500,500);
rec.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
rec.setVisible(true);
}
public TwoBRandomRec() {
//Create the buttons
JButton north = new JButton("North");
JButton south = new JButton("South");
DrawPanel drawPanel = new DrawPanel(500,500);
JPanel southP = new JPanel();
southP.add(south);
southP.add(north);
this.add(drawPanel, BorderLayout.CENTER);
this.add(southP, BorderLayout.SOUTH);
this.setTitle("TwoButtonRandomRec");
this.pack();
}
public class DrawPanel extends JPanel { …Run Code Online (Sandbox Code Playgroud) 我想知道是否有办法在iOS上使用C++获取对Documents文件夹的引用(即没有在Objective-C中使用任何代码;这是因为它是一个仅在C++中实现的框架,可以作为库添加在iOS项目中).
如果可能,请在答案中提供代码.
在创建ABAddressBook对象时,我在iOS6上收到以下警告.我这样使用它:
ABAddressBook ab = new ABAddressBook ();
Run Code Online (Sandbox Code Playgroud)
结果:
Warning CS0618: `MonoTouch.AddressBook.ABAddressBook.ABAddressBook()' is obsolete: `Use static Create method in iOS 6.0' (CS0618)
Run Code Online (Sandbox Code Playgroud)
我应该如何使用上面提到的静态方法?
如何将热键挂钩到我的应用程序,以便,例如,如果我按CTRL+ F2它显示消息"hello world",即使应用程序被最小化或在其他应用程序上工作等?请告诉我示例或来源.
我正在实施自定义UIMenuController并试图找出答案.我怎样才能合法地禁用"复制"和"定义"的UIMenuItems UIMenuController的UITextfield?Textfield不可编辑.我尝试使用以下命令禁用"复制":
-(BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
if (action == @selector(copy:))
{
return NO;
}
return [super canPerformAction:action withSender:sender];
}
- (IBAction)tapTextViewGesture:(id)sender {
UIMenuItem *myItem1 = [[UIMenuItem alloc] initWithTitle:@"myItem1" action:@selector(myItem1Pressed:)];
UIMenuItem *myItem2 = [[UIMenuItem alloc] initWithTitle:@"myItem2" action:@selector(myItem2Pressed:)];
UIMenuItem *myItem3 = [[UIMenuItem alloc] initWithTitle:@"myItem3" action:@selector(myItem3Pressed:)];
// Access the application's shared menu
UIMenuController *menu = [UIMenuController sharedMenuController];
[menu setMenuItems:[NSArray arrayWithObjects:myItem1,myItem2,myItem3, nil]];
CGRect menuRect = CGRectMake(20, 50, 200, 0);
// Show the menu from the cursor's position
[menu setTargetRect:menuRect inView:self.view]; …Run Code Online (Sandbox Code Playgroud) 我正计划进行库存数据库设计,以便跟踪我们店里的产品.我正在考虑在数据库中存储一个具有所有大小和颜色的数组,如:
array('S-groen' => 6,'M-groen' => 0,'L-groen' => 2,'S-zwart' => 9,'M-zwart' => 0,'L-zwart' => 3);
Run Code Online (Sandbox Code Playgroud)
S是大小,而groen是颜色.
但这样做是好的做法,还是有更好的方法?
所以我的数据库将是:ID - product_id - aantal.在aantal将是阵列.