小编Man*_*ody的帖子

在Swift中UIImageWriteToSavedPhotosAlbum之后的图像的URL

在我用相机拍照后,我使用以下代码保存图像:

UIImageWriteToSavedPhotosAlbum(image, self,"image:didFinishSavingWithError:contextInfo:", nil)
Run Code Online (Sandbox Code Playgroud)

这样可以将图像保存在相机胶卷中.此外,我想将URL保存到Core Data中保存的图像.是否可以检索URL(或路径),以便我只需要保存此URL而不是Core Data中的完整图像?

xcode ios swift ios8

13
推荐指数
1
解决办法
6581
查看次数

在Angular2中捕获401异常

当我尝试连接到未经授权的网址时,我会进入Chrome:

zone.js:1274 POST http://localhost:8080/rest/v1/runs 401 (Unauthorized)
core.umd.js:3462 EXCEPTION: Response with status: 401 Unauthorized for URL: http://localhost:8080/rest/v1/runs
Run Code Online (Sandbox Code Playgroud)

我的Home Component的代码是:

import {Component, OnInit} from '@angular/core';
import {Run} from "../_models/run";
import {Http, Response} from "@angular/http";
import {RunService} from "../_services/run.service";
import {Observable} from "rxjs";

@Component({
    moduleId: module.id,
    templateUrl: 'home.component.html'
})

export class HomeComponent implements OnInit{
    url: "http://localhost:8080/rest/v1/runs"
    username: string;
    runs: Run[];

    constructor(private http: Http, private runService: RunService) {

    }

    ngOnInit(): void {
        this.username = JSON.parse(localStorage.getItem("currentUser")).username;
        this.runService.getRuns()
            .subscribe(runs => {
                this.runs = runs;
            });
    } …
Run Code Online (Sandbox Code Playgroud)

exception http-status-code-401 angular

8
推荐指数
1
解决办法
2万
查看次数

在Haskell中更改记录值

我正在尝试使用以下代码编写Haskell模块:

module RectangleMover where

data Rectangle = Rectangle { xCoordinate :: Int
                           , yCoordinate :: Int
                           , width :: Int
                           , height :: Int
                           } deriving (Show)

move :: Rectangle -> Int -> Int -> Rectangle
-- Edit 1
move rec x y =
    let rec' = { xCoordinate + x
               , yCoordinate + y
               }
    return rec
Run Code Online (Sandbox Code Playgroud)

要创建一个矩形,我会输入:

let rec = Rectangle 10 10 20 30
Run Code Online (Sandbox Code Playgroud)

但我现在的问题是如何实现一个"移动"这个矩形的函数?在C#或Java中,调用将是这样的:rec.move(20,20); 但是如何在Haskell中编写?

不幸的是,我第一次尝试使用函数式编程语言......

编辑1: 我在我的函数中添加了代码,但仍然在"xCoordinate + x"处得到解析错误...

haskell record

4
推荐指数
3
解决办法
2397
查看次数

标签 统计

angular ×1

exception ×1

haskell ×1

http-status-code-401 ×1

ios ×1

ios8 ×1

record ×1

swift ×1

xcode ×1