小编fur*_*ani的帖子

iOS7 - 设备唯一标识符

我们的iOS应用程序适用于特定用户.因此,我们使用设备唯一标识符进行用户识别.这种方法适用于iOS 6,因为我们每次都获得相同的价值.

NSString *strUniqueIdentifier = [[UIDevice currentDevice] uniqueIdentifier];
Run Code Online (Sandbox Code Playgroud)

在iOS 7中,上述方法重新调整了不同的值,我们在用户识别方面遇到了问题.iOS 7 apis提供以下备用.

NSUUID *oNSUUID = [[UIDevice currentDevice] identifierForVendor];
[strApplicationUUID setString:[oNSUUID UUIDString]];
Run Code Online (Sandbox Code Playgroud)

我用"identifierForVendor"替换了"uniqueIdentifier",并创建了Ad hoc构建.在iOS 7和iOS 6设备上安装了构建版本.在iOS 7中,到目前为止,我每次都获得相同的值,但是当我们删除并重新安装应用程序时,iOS 6每次都会给出不同的值.

目前App Store上没有应用程序.所以我不确定这个API如何适用于App Store构建.

问题:1)对于appstore app,"identifierForVendor"每次都返回iOS 7的相同值吗?或者以后用户删除并重新安装应用程序时可能会更改?2)iOS 7 apis中的"唯一标识符"是否有其他替代选项,它们为iOS 6和7返回相同的值?3)任何其他建议......

objective-c uniqueidentifier ios ios7

23
推荐指数
2
解决办法
7万
查看次数

我们如何测试非范围角度控制器方法?

我们在Angular Controller中有很少的方法,它们不在范围变量上.

有谁知道,我们如何在Jasmine测试中执行或调用这些方法?

这是主要代码.

var testController = TestModule.controller('testController', function($scope, testService)
{

function handleSuccessOfAPI(data) {
    if (angular.isObject(data))
    {
       $scope.testData = data;
    }
}

function handleFailureOfAPI(status) {
    console.log("handleFailureOfAPIexecuted :: status :: "+status);
}

 // this is controller initialize function.
 function init() {
    $scope.testData = null; 

    // partial URL
    $scope.strPartialTestURL = "partials/testView.html;

    // send test http request 
    testService.getTestDataFromServer('testURI', handleSuccessOfAPI, handleFailureOfAPI);
}

 init();
}
Run Code Online (Sandbox Code Playgroud)

现在在我的茉莉花测试中,我们传递"handleSuccessOfAPI"和"handleFailureOfAPI"方法,但这些都是未定义的.

这是茉莉花测试代码.

describe('Unit Test :: Test Controller', function() {
var scope;
var testController;

var httpBackend;
var testService;


beforeEach( function() { …
Run Code Online (Sandbox Code Playgroud)

jasmine angularjs karma-runner angularjs-controller angularjs-http

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

无法在PhantomJS浏览器中执行karma单元测试

在grunt中,我们通过以下方式在PhantomJs中执行单元测试.

karma: {
        options: {
    configFile: 'karma.conf.js',
    runnerPort: 9876,
    browsers: ['Chrome']
    },
unitTestDev: {
        browsers: ['PhantomJS'],
        singleRun: true
     }
}

grunt.registerTask('unitTest',['karma:unitTestDev']);
Run Code Online (Sandbox Code Playgroud)

这是karma.conf.js文件.

    // Karma configuration
// Generated on Thu Apr 03 2014 13:44:39 GMT-0500 (Central Daylight Time)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],


    // list of files / patterns to load in the browser
    files: …
Run Code Online (Sandbox Code Playgroud)

unit-testing jasmine phantomjs gruntjs karma-runner

7
推荐指数
1
解决办法
4357
查看次数