小编Hac*_*ckU的帖子

Objective-C ^运算符

我是Objective C的新手并试图找出^运算符是什么?在探索一些源代码时,我看到了下一个构造:

dispatch_once(&onceToken, ^{
    UIGraphicsBeginImageContextWithOptions(CGSizeMake(20.f, 13.f), NO, 0.0f);

    [[UIColor blackColor] setFill];
    [[UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 20, 1)] fill];
    [[UIBezierPath bezierPathWithRect:CGRectMake(0, 5, 20, 1)] fill];
    [[UIBezierPath bezierPathWithRect:CGRectMake(0, 10, 20, 1)] fill];

    [[UIColor whiteColor] setFill];
    [[UIBezierPath bezierPathWithRect:CGRectMake(0, 1, 20, 2)] fill];
    [[UIBezierPath bezierPathWithRect:CGRectMake(0, 6,  20, 2)] fill];
    [[UIBezierPath bezierPathWithRect:CGRectMake(0, 11, 20, 2)] fill];   

    defaultImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

});
Run Code Online (Sandbox Code Playgroud)

而且我想知道^是什么?

objective-c ios

9
推荐指数
2
解决办法
691
查看次数

Play 2.0框架 - POST参数

我正在尝试将参数POST到Action,并在路由中写道:

# Home page
GET    /                         controllers.Application.index()

POST   /login/name:/password:    controllers.Application.login(name, password)
Run Code Online (Sandbox Code Playgroud)

我有一个动作

public static Result login(String name, String password) {
    return ok(name + " "  + password);
}
Run Code Online (Sandbox Code Playgroud)

我的表格是

<form action="/login" method="post">

    <input name="name" type="text" id="name">
    <input name="password" type="password" id="password">
    <input type="submit" value="Login">

</form>
Run Code Online (Sandbox Code Playgroud)

它不起作用

如有要求 'POST /login' [Missing parameter: name]

我究竟做错了什么?

model-view-controller url-routing playframework

5
推荐指数
1
解决办法
7141
查看次数

Java 8使用stream()将List <Object>提取/转换为Map <String,List <String >>

试图找出如何有效地在我的代码中使用新的Java 8特性.stream().

这是我的一般代码

List<Item> list = db.query(sqlStatement, (rs, i) -> new Item(rs));

    Map<String, List<Item>> itemsByName = new HashMap<>();

    for (Item m : list) {
        if (!itemsByName.containsKey(m.getName())) {

            ArrayList<Item> items = new ArrayList<>();
                            items.add(m);

            itemsByName.put(m.getName(), items);
        } else {
            itemsByName.get(m.getName()).add(m);
        }
    }
Run Code Online (Sandbox Code Playgroud)

由此(1)

List<Item> list = db.query(sqlStatement, (rs, i) -> new Item(rs));
Run Code Online (Sandbox Code Playgroud)

我得到的项目列表看起来像:

list(0):Name1:Value1

list(1):Name1:Value2

list(2):Name2:Value1

list(3):Name3:Value3

由此(2)

Map<String, List<Item>> itemsByName = new HashMap<>();

    for (Item m : list) {
        if (!itemsByName.containsKey(m.getName())) {

            ArrayList<Item> items = new ArrayList<>();
                            items.add(m);

            itemsByName.put(m.getName(), items); …
Run Code Online (Sandbox Code Playgroud)

java collections lambda java-8 java-stream

3
推荐指数
1
解决办法
694
查看次数