无法在swift中键入“String”类型的值以键入“UILabel”

时间:2015-07-01 05:31:23

标签: ios string swift uilabel uint32

我正在编写一个关于数学测试​​随机生成器的程序。 但是当我创建一个随机操作时。我使用arc4random_uniform()来创建一个随机数。这是功能。

func generateQuestion() {
        var randomoperation:UInt32 = arc4random_uniform(3)
        if randomoperation == 0 {
            operation = "+"
        }
        if randomoperation == 1 {
            operation = "-"
        }
        if randomoperation == 2 {
            operation = "X"
        }
        if randomoperation == 3 {
            operation = "/"
        }
    }

这会在swift中创建错误“无法分配值类型”字符串“以键入”UILabel“ 你是如何解决这个问题的?

2 个答案:

答案 0 :(得分:1)

files=240

buffers=60

答案 1 :(得分:0)

我认为<!DOCTYPE html> <html ng-app="app"> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <!--our controller--> <div ng-controller="ItemController"> <button id="get-items-button" ng-click="getItems()">Get Items</button> <p>Look at the list of items!</p> <!--this table shows the items we get from our service--> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th>Description</th> <th>Done</th> <th>Title</th> <th>URI</th> </tr> </thead> <tbody> <!--repeat this table row for each task in tasks--> <tr ng-repeat="task in tasks"> <td>{{task.description}}</td> <td>{{task.done}}</td> <td>{{task.title}}</td> <td>{{task.uri}}</td> </tr> </tbody> </table> </div> <script> (function () { //create our module angular.module('app', []) //add controller .controller('ItemController', function ($scope, $http) { //declare an array of items. this will get populated with our ajax call $scope.tasks = []; //declare an action for our button $scope.getItems = function () { //perform ajax call. $http({ url: "/todo/api/v1.0/tasks", method: "GET" }).success(function (data, status, headers, config) { //copy the data we get to our items array. we need to use angular.copy so that //angular can track the object and bind it automatically. angular.copy(data.tasks, $scope.tasks); }).error(function (data, status, headers, config) { //something went wrong alert('Error getting data'); }); } }); console.log($scope.tasks); })(); </script> </body> </html> 是您的标签名称,因此您可以通过以下方式为其指定文字:

operation

阅读此Apple Documentation以获取更多信息。