List<Location> locations = SAXXMLParsertest.parse("Your xml data");
if (locations != null && locations.size() > 0) {
for (int i = 0; i < locations.size(); i++) {
Log.e("Location name", " " + locations.get(i).getLocationName());
Log.e("Location Id", " " + locations.get(i).getLocationID());
Log.e("Photo Uri", " " + locations.get(i).getPhotoURL());
}
}
无法分配二元运算符'+'
答案 0 :(得分:0)
&#34; dataArray&#34;声明?
是[AnyObject]还是[Double]
如果是前者,您需要使用以下方法将其强制转换为:
guard let price = totalPrice as? Double else { continue }
money = money + totalPrice
答案 1 :(得分:0)
totalPrice是Double
的类型。我认为应该有某种类型的NSDecimalNumber
不是你的类型?
此外,当您处理货币数据时,请检查Double
。 $mask = 210;
会丢失很多数字。
答案 2 :(得分:0)
问题是您的 dataArray 是 AnyObject 类型的数组。如果它真的包含双精度数,你可以像这样迭代:
> myapp-front@1.0.0 start /home/pln/dev/myprojects/myprojects/myapp-front
> concurrent "npm run tsc:w" "npm run lite"
[0]
[0] > myapp-front@1.0.0 tsc:w /home/pln/dev/myprojects/myprojects/myapp-front
[0] > tsc -w
[0]
[1]
[1] > myapp-front@1.0.0 lite /home/pln/dev/myprojects/myprojects/myapp-front
[1] > lite-server
[1]
[1] [BS] Access URLs:
[1] -------------------------------------
[1] Local: http://localhost:3000
[1] External: http://192.168.0.47:3000
[1] -------------------------------------
[1] UI: http://localhost:3001
[1] UI External: http://192.168.0.47:3001
[1] -------------------------------------
[1] [BS] Serving files from: ./
[1] [BS] Watching files...
[0] 09:04:01 - Compilation complete. Watching for file changes.
[1] [BS] File changed: app/app.component.js
[1] [BS] File changed: app/boot.js
[1] events.js:85
[1] throw er; // Unhandled 'error' event
[1] ^
[1] Error: watch ENOSPC
[1] at exports._errnoException (util.js:746:11)
[1] at FSWatcher.start (fs.js:1172:11)
[1] at Object.fs.watch (fs.js:1198:11)
[1] at createFsWatchInstance (/home/pln/dev/myprojects/myprojects/myapp-front/node_modules/lite-server/node_modules/browser-sync/node_modules/chokidar/lib/nodefs-handler.js:37:15)
[1] at setFsWatchListener (/home/pln/dev/myprojects/myprojects/myapp-front/node_modules/lite-server/node_modules/browser-sync/node_modules/chokidar/lib/nodefs-handler.js:80:15)
[1] at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/pln/dev/myprojects/myprojects/myapp-front/node_modules/lite-server/node_modules/browser-sync/node_modules/chokidar/lib/nodefs-handler.js:228:14)
[1] at FSWatcher.NodeFsHandler._handleFile (/home/pln/dev/myprojects/myprojects/myapp-front/node_modules/lite-server/node_modules/browser-sync/node_modules/chokidar/lib/nodefs-handler.js:255:21)
[1] at FSWatcher.<anonymous> (/home/pln/dev/myprojects/myprojects/myapp-front/node_modules/lite-server/node_modules/browser-sync/node_modules/chokidar/lib/nodefs-handler.js:473:21)
[1] at FSReqWrap.oncomplete (fs.js:95:15)
[1]
[1] npm
[1]
[1] ERR!
[1] Linux 3.16.0-56-generic
[1] npm
[1] ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "lite"
[1] npm ERR! node
[1] v0.12.9
[1] npm ERR! npm
[1] v2.14.9
[1] npm
[1] ERR! code ELIFECYCLE
[1] npm
[1] ERR! myapp-front@1.0.0 lite: `lite-server`
[1] npm
[1] ERR! Exit status 1
[1] npm
[1] ERR!
[1] npm
[1] ERR!
[1] Failed at the myapp-front@1.0.0 lite script 'lite-server'.
[1] npm ERR! This is most likely a problem with the myapp-front package,
[1] npm ERR! not with npm itself.
[1] npm ERR! Tell the author that this fails on your system:
[1] npm ERR! lite-server
[1] npm ERR! You can get their info via:
[1] npm ERR! npm owner ls myapp-front
[1] npm ERR!
[1] There is likely additional logging output above.
[1]
[1] npm ERR! Please include the following file with any support request:
[1] npm
[1] ERR! /home/pln/dev/myprojects/myprojects/myapp-front/npm-debug.log
[1] npm run lite exited with code 1