• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
OCMock + Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

OCMock + Swift


  • Subject: OCMock + Swift
  • From: email@hidden
  • Date: Fri, 13 Jun 2014 14:11:27 -0700

Hey Xcode Users,
  I’m trying to get OCMock up and running in a small swift app and I can’t get the expectations part of the mock working. Normally in ObjC I’d write something like this:

CGRect frame = CGRectMake(0.0f, 0.0f, 320.0f, 468.0f);
id mockWindow = [OCMockObject mockForClass:[UIWindow class]];
[[mockWindow expect] setFrame:frame];

I thought I might translate that to this in Swift:

var frame: CGRect = CGRectMake(0.0, 0.0, 320.0, 468.0)
var mockWindow: AnyObject = OCMockObject.mockForClass(UIWindow)
mockWindow.expect().setFrame(frame)

But this doesn’t work, the compiler complains with:

/Users/nick/Source/SwiftTest/SwiftTestTests/AppDelegateTest.swift:38:18: '(@lvalue CGRect) -> $T5' is not identical to ‘CGRect'

Any thoughts on what I’m doing wrong?

Cheers.

Nick
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Storyboard - Unembed
  • Next by Date: CSSM_SignData returned: 8001094A
  • Previous by thread: Storyboard - Unembed
  • Next by thread: CSSM_SignData returned: 8001094A
  • Index(es):
    • Date
    • Thread