1

Working on a weird setup where my main development machine is running Snow Leopard (and thus, just has iOS 5.0 SDK) and also have a laptop running Lion (and 5.1SDK). Wish I had a simple solution to be able to develop 5.1 on the Snow Leopard machine, but that's a side issue.

I'm learning UISplitViewControllers, and wanted to have a swipe gesture to change what's being shown in the detail view controller. Implemented that, but in 5.1, there's a property called presentsWithGesture that reveals the masterViewController when you swipe that direction.

You can disable it, but my 5.0 machine gives me an error saying (correct for 5.0) that UISplitViewController doesn't have a property named presentedWithGesture.

Sigh... so I thought I'd test for it, but the following:

if (self.splitViewController.presentedViewController) {
    self.splitViewController.presentsWithGesture = NO;
}

... still gives me that error. Is there a clever way to get around this? Some voice in the back of my head says "categories," but I'm unsure where to start.

Thanks in advance for your help.

james Burns
  • 864
  • 2
  • 9
  • 22

2 Answers2

1

This is the way to check if theUISplitViewController has the presentsWithGestureProperty:

if ([m_splitVC respondsToSelector:@selector(setPresentsWithGesture:)])
    [m_splitVC setPresentsWithGesture:NO];

In iOS 5.1 it will set the property and in previous versions it will not enter the if statement.

Druid
  • 6,423
  • 4
  • 41
  • 56
Ralph
  • 716
  • 5
  • 9
0

You should ask the splitViewController if it can receive the message presentsWithGesture.

if ([splitViewController respondsToSelector:@selector(presentsWithGesture:)]) {
    //edited away from dot syntax
    [splitViewController setPresentsWithGesture:NO];
}

Keep in mind that this is a code block for working with users who may not be using the same version of iOS that you're linking against. The problem you're having is the opposite, in that you're writing code for the same project on two separate devices, each with a different base SDK.

Edit: see here Is it possible to get the iOS 5.1 SDK for Xcode 4.2 on Snow Leopard?

Community
  • 1
  • 1
Daddy
  • 9,045
  • 7
  • 69
  • 98
  • That's basically what I'm doing in my code. Your way is more standard (and better) but it doesn't resolve the error flag. I still get: error: Semantic Issue: Property 'presentsWithGesture' not found on object of type 'UISplitViewController *' – james Burns May 08 '12 at 17:14
  • Thanks for the effort, but I get the exact same error. I believe the dot syntax is just a way to access the setter, but I also tried that variation earlier, just in case. – james Burns May 08 '12 at 17:28
  • by using the actual setter method you should just get a compiler warning that UISplitViewController may not respond to the message presentsWithGesture. Maybe your project settings treats warnings the same as errors. – Daddy May 08 '12 at 17:30
  • No. My project isn't set up that way. I feel like you just get those gentle warnings if you're casting an ID or something. – james Burns May 08 '12 at 17:47
  • I updated my answer with a link to another SO question on using XCode 4.2 with iOS 5.1 in SL – Daddy May 08 '12 at 17:51