小编tur*_*e02的帖子

将拾取的图像保存到CoreData

我可以从照片库中选择并显示图像,但我的目标是能够将选择的图像或文件路径保存到核心数据,以便在选择保存的记录时也会显示图像.

我有CoreData工作,我能够从CoreData显示文本很好,它只是图像阻止我.

@IBAction func addPic(sender: AnyObject) {
pickerController.delegate = self
pickerController.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
// 2
self.presentViewController(pickerController, animated: true, completion: nil)

// Displays image
func imagePickerController(picker: UIImagePickerController!,didFinishPickingMediaWithInfo info: NSDictionary!){
image.image = info[UIImagePickerControllerOriginalImage] as? UIImage

self.dismissViewControllerAnimated(true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

core-data uiimagepickercontroller uiimage swift

33
推荐指数
1
解决办法
4万
查看次数

Python请求和Json for循环

我试图循环附加的JSON并打印出数据中每个项目的名称和价格.我的问题是它重复打印出的名字和价格不超过50次.我错过了什么?什么会让我让它显示下一个项目?这只是一个基于代码的示例数据.

我的守则

import json
import requests

request = requests.get('http://example.com/json')

for item in request:
    data = request.json()
    data = data['items'][0]
    price = data['salePrice']
    name = data['name']
    print name
Run Code Online (Sandbox Code Playgroud)

数据

    {"items":[ {
  "itemId" : 5969538,
  "parentItemId" : 5969538,
  "name" : "Breakfast Nook 3 Piece Corner Dining Set, Black",
  "salePrice" : 288.99,
  "shortDescription" : "Create extra space and a cozy area to dine and relax with this stylish nook corner dining set. A rich black finish adds sophistication to any dining area, while …
Run Code Online (Sandbox Code Playgroud)

python json

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