在我用相机拍照后,我使用以下代码保存图像:
UIImageWriteToSavedPhotosAlbum(image, self,"image:didFinishSavingWithError:contextInfo:", nil)
Run Code Online (Sandbox Code Playgroud)
这样可以将图像保存在相机胶卷中.此外,我想将URL保存到Core Data中保存的图像.是否可以检索URL(或路径),以便我只需要保存此URL而不是Core Data中的完整图像?
当我尝试连接到未经授权的网址时,我会进入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) 我正在尝试使用以下代码编写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"处得到解析错误...