I'm beginning some OS X development, I am reasonably accomplished with objective C and UIKIT.
There doesn't seem to be as much online about moving from iOS development to OS X as I thought there would be!
Anyway, I found a decent tutorial over a Ray Wenderlich, that basically explained the differences, (multiple NSWindows, then add to them NSViewControllers etc)
What I would like to do is make a little app that shows info in the status bar (beside the Wifi icon etc)
Basically all it does is have an NSStatusitem that has it's title set with info I want shown (e.g. current song title)
I've got one going and it's working ok so to my question:
I've got Application is agent (UIElement) (so I cannot see a dock icon or menubar)
The code for my little app all resides in the app delegate, now from iOS dev i'm sure this is not the right place for this code, but since the app is a just a status bar item, that has it's title updated I don't think I need a UIViewController etc....
Where should my apps logic go?
Anything online to transition from iOS to OS X?
As you dont have much work with NSWindows and NSViews, you surely dont need NSWindowController or NSViewController.
And I think for this kind of app even your AppDelegate class is enough and best place to put all your logic.
If you have some models then you can break your code upto that, and use it in the AppDelegate itself.
Transition from iOS to OSX.
If you are good in Objective-C then you dont have to worry about few more Cocoa-Controls especially GUI levels, you have full support of Documentation.
Switching between iOS to OSX, vice-versa is not to difficult, but yes if you end up with system level then you need to interact with OSX too.
As stated earlier, if you know Objective-C well, then you should not face major problems. However, there are some differences. I found these following documents helpful:
About Developing for Mac
Migrating from Cocoa Touch
Related
I already have a webview in my Mac app. Now I need to implement tabs like Safari (for example). I searched some and didn't got any one for Cocoa App. Some libraries I found was too old and was not able to change it to running condition. I found a lot for iOS apps Cocoa Touch. Is there any solution for giving tabs for a webview?
IF THIS IS A DUPLICATE QUESTION, PLEASE MENTION AT LEAST AN ALMOST EXACT ORIGINAL
OBJECTIVE - C PLEASE
For tabs, NSWindow provides all the functionality you need. Basically, you get tabs for free, including the ability for users to drag/drop tabs to windows and vice versa.
For grouping several windows/tabs together, there is webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures: in the UI delegate, which tells you how to open the new window/tab and gives you an opportunity to set the webview up.
So I am creating an app that will be released in the App Store available for iPhone 4/4s and iPhone 5.
In my project I am using storyboard for the interface.
At the moment not every object is able to aline perfect with the objects above so when I for example test on iphone 4 every thing gets messed up.
How can I fix the place of the object.
Do I have to hardcode this? Or can I use storyboard for this.
I think autolayout should suffice in most cases. You can check out a comprehensive tutorial here: http://floatlearning.com/2012/11/designing-for-multiple-screens-in-ios/
I have a native objective c ios application that I would like to convert to run on my Mac. How could I begin such a journey? Is there a way to run a native objective c ios app on a mac without ios simulator? Or some sort of in place framework I can use?
Although your logic code will be fairly portable, there is no quick way to port an app from iOS to OS X. The only way to do this is to create a new app from the Xcode template and move your code accordingly.
Remember, the View paradigm in OS X is completely different than iOS (i.e. UITableView vs. NSTableView). How will you handle user input? Is a series of tableviews the best way or would an NSBrowser work better?
There are many things to consider and at the end of the day you'll need to account for that when creating your new app.
You are going to have to re-implement the GUI in App kit, App Kit uses a lot of the same design patterns as UIKit, delegation, datasources, view controllers, View hierarchy with views having a bounds and a frame, responder chain, Nib files, if you are competent with iOS programming you will pick up Mac OS X very quickly. If your application is structured with good business logic separation from your GUI, you will be able to use all your model classes with little or no modification. Foundation Kit, Core Data and others are on both platforms and they are very similar, it is usually the case that the iOS versions have reduced API and so going other direction, Mac OS X to iOS, can require some work, for example iOS does not have NSXMLDocument classes.
I am in the process of writing a menubar icon for an app i'm developing. However the NSStatusBar class does not have a method which would make the icon draggable, via cmd+left mouse drag.
How do you make your menubar icon draggable with Objective-C code?
Thank you :)
You can't currently do it with NSStatusBar. NSMenuExtra will behave the the way you want, but unfortunately it's not part of the part of the public Cocoa API, and from what I understand (I haven't used it myself) takes a bit of a hack to even get it working. Also NSStatusBar will be easier to integrate into an existing application, NSMenuExtra is more of a separate bundle that's loaded by the system.
In my opinion it's not a good idea to depend on private APIs to add major functionality like this to your app. I would stick with NSStatusBar, most users will be used to the behavior from other applications, and with any luck a future version of Mac OS X will allow dragging the icon the same way NSMenuExtra works.
Developing for the iPhone has been my first experience with objective-c and first in-depth experience with xcode. How difficult would it be to port an openGLES iPhone app to the OSX desktop using openGL? I am not asking about user interface - obviously there is no equivalent to cocoa touch UI on the desktop. I am asking specifically about the app delegate and openGLES layers. Are there any major hurdles? Is it as straight forward as simply creating a new app delegate in a project of type cocoa?
I've started looking into just the same thing, and it appears that OpenGL-heavy applications would be among the easiest to backport to the Mac. Pretty much everything in OpenGL ES is present in OpenGL on the desktop (with the exception of some of the fixed-point stuff), so that code can stay the same.
The way that OpenGL is handled on the iPhone is via a Core Animation layer (CAEAGLLayer), rather than a specific view. Therefore, you should be able to transfer that across to a Leopard-based desktop application, although you'll need to convert all references to EAGL classes to their OpenGL equivalent (EAGLContext to NSOpenGLContext, for example). You could render into a CAOpenGLLayer that's displayed by itself, or use that layer to back a custom NSView.
The fundamental structure of a desktop Cocoa application will be different than a Cocoa Touch one, but you should be able to start from one of the Xcode templates and add back in your components from the Cocoa Touch application.
Again, I haven't yet done this for my application, but it looks reasonably straightforward.