小编Fir*_*ule的帖子

XCode得到"目标指定产品类型'com.apple.product-type.bundle.unit-test',但'iphoneos'平台没有这样的产品类型"

在XCode中运行我的项目时,我的测试给出了以下错误:

target specifies product type 'com.apple.product-type.bundle.unit-test', but there's no such product type for the 'iphoneos' platform
Run Code Online (Sandbox Code Playgroud)

它发生在几次XCode更新之后.有谁知道如何解决这一问题?

xcode unit-testing objective-c ios xcode6

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

在Swift中将CGFloat转换为NSNumber

我在Swift中有一个扩展,它包含了一些属性CGFloat.问题是我不知道如何使用关联对象获取存储的CGFloatNSNumber

这是我的代码不起作用,但它详细说明了我想做的事情:

var scaledFontSize: CGFloat {
    get {
        guard let fontSize = objc_getAssociatedObject(self, &AssociatedKeys.scaledFontSize) as? NSNumber else {
            //Set it
            let scaledFont:CGFloat = VGSizeValues.getValueFromValue(self.font.pointSize);
                //Fails here
            objc_setAssociatedObject(self,&AssociatedKeys.scaledFontSize, NSNumber( scaledFont),objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
            return scaledFont;
        }
        return CGFloat(fontSize.doubleValue);

    }
}
Run Code Online (Sandbox Code Playgroud)

有没有办法解决这个问题?

casting nsnumber cgfloat ios swift

27
推荐指数
3
解决办法
1万
查看次数

Xcode 7.0 XCTest dyld:无法加载插入的库IDEBundleInjection

我在我的iOS项目上运行单元测试,当它运行时,它会崩溃并吐出来:

dyld: could not load inserted library '/private/var/mobile/Containers/Data/Application/1CAB64C8-D730-427B-8E9E-BD5E152ACFD6/tmp/IDEBundleInjection.framework/IDEBundleInjection' because no suitable image found.  Did find:
/private/var/mobile/Containers/Data/Application/1CAB64C8-D730-427B-8E9E-BD5E152ACFD6/tmp/IDEBundleInjection.framework/IDEBundleInjection: mmap() error 1 at address=0x00436000, size=0x00004000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Data/Application/1CAB64C8-D730-427B-8E9E-BD5E152ACFD6/tmp/IDEBundleInjection.framework/IDEBundleInjection
Run Code Online (Sandbox Code Playgroud)

我正在使用XCode 7.0并在运行iOS 8.3的iPod上进行测试.我删除了派生数据,我重新启动了XCode,但它仍然没有工作.

xcode dyld ios xctest xcode7

21
推荐指数
2
解决办法
4414
查看次数

如何检测Swift 2中的所有触摸

我正在尝试为我正在使用Swift 2开发的应用程序创建超时功能,但在swift 2中,您可以将此代码放在应用程序委托中并且它可以工作,但它不会检测到任何键盘按下,按钮按下,文本字段按下, 等等:

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
    super.touchesBegan(touches, withEvent: event);
    let allTouches = event!.allTouches();

    if(allTouches?.count > 0) {
        let phase = (allTouches!.first as UITouch!).phase;
        if(phase == UITouchPhase.Began || phase == UITouchPhase.Ended) {
            //Stuff
            timeoutModel.actionPerformed();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在swift 2之前,我能够拥有AppDelegate子类UIApplication并覆盖sendEvent:像这样:

-(void)sendEvent:(UIEvent *)event
{
    [super sendEvent:event];

    // Only want to reset the timer on a Began touch or an Ended touch, to reduce the number of timer resets.
    NSSet *allTouches = [event allTouches];
    if ([allTouches count] > …
Run Code Online (Sandbox Code Playgroud)

timeout touch ios appdelegate swift2

5
推荐指数
1
解决办法
5322
查看次数

CGAffineTransformRotate和M_PI不一致(Objective-C,iOS)

我正在尝试在Objective-C中进行简单的旋转,并且有一些问题.有一件事是我从CGAffineTransformRotate得到的不一致以及在该函数中使用时M_PI如何不一致.

假设我这样做,并将其附加到按钮上.当我按下它一次它将逆时针旋转180度(良好并遵循文档)但当我再次按它时,它将顺时针旋转180,即使该值不是负的.将M_PI更改为-M_PI完全相同,旋转没有差异:

[UIView animateWithDuration:secs delay:0.0 options:option
   animations:^{
      self.transform = CGAffineTransformRotate(self.transform, M_PI);   //Inconsistent
} completion:nil];
Run Code Online (Sandbox Code Playgroud)

现在假设我将M_PI更改为3.141593,这是我打印时M_PI包含的值.现在,当我按下按钮时,它完全正常.两次,它都会逆时针旋转180度.当我将它改为-3.141593时,它也会完全正常工作,顺时针:

self.transform = CGAffineTransformRotate(self.transform, 3.141593);   //Works
Run Code Online (Sandbox Code Playgroud)

当我更多地玩它时,行为变得更加奇怪.

假设我想旋转90度(pi/2).M_PI现在具有与使用值相同的行为,但旋转与它应该是相反的:

//Should be Clockwise but rotates CounterClockwise
self.transform = CGAffineTransformRotate(self.transform, -M_PI/2);  
self.transform = CGAffineTransformRotate(self.transform, -1.5707965); 

//Should be CounterClockwise but rotates Clockwise
self.transform = CGAffineTransformRotate(self.transform, M_PI/2);  
self.transform = CGAffineTransformRotate(self.transform, 1.5707965);
Run Code Online (Sandbox Code Playgroud)

如果我想旋转超过180度(PI)的任何东西,即使我指定正或负旋转,行为也只是旋转最短路线.当我旋转360度(2PI)时,它甚至不会旋转.

为什么会发生这些事情,我该怎么做才能使它更加一致?我的第二个问题是如何旋转270度和360度的东西.

objective-c rotation cgaffinetransform ios

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

Scala:一个声明自己为变量的类

我正在尝试在scala中创建一个二叉树,并且需要为它创建一个方法,所以我试图在类中处理子项和子项.我想让父树成为一个树,以便我可以在另一个名为getPath的函数中递归调用它,但我不能在Tree类中创建一个Tree.这是代码:

case class Tree[+T](value: T, left: Option[Tree[T]], right: Option[Tree[T]]) {
   var parent: Tree[T] = null

   //method for setting the parent of tree.
   //this method returns the parent TREE instead of the parent value
   //so if you want to use it to find the value, you need to get the parent.value
   def setParent(tree: Tree[T]) {
 parent = tree
   }

   //method for returning the parent
   //the parent is a tree so you have to .value it to get the root
   def getParent(): …
Run Code Online (Sandbox Code Playgroud)

tree types scala path covariance

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

XCode 6 中的自定义字体未加载到模拟器上

我正在为 iPad 编写一个应用程序,并在其中使用自定义字体。自定义字体已添加到我的 Mac 字体簿中,并显示在故事板编辑器中。我还可以在编辑器上选择自定义字体,它会在故事板中完美呈现。问题是当我将应用程序加载到模拟器时,它不使用自定义字体,而是使用系统字体。这适用于 UILabel、UIButton 和 UITextField,但我还没有测试过其他任何东西。

我错过了一些设置还是什么?

fonts ios swift xcode6

-1
推荐指数
1
解决办法
1131
查看次数