Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 24, 2013, 11:55 AM   #1
W5UXH
macrumors newbie
 
Join Date: Dec 2012
Learning Xcode: Looking for references / examples

I am attempting to learn the fundamentals of how to build OS X (10.8.3) GUI applications using Xcode 4.6.2. I apologize for this long post, but I want to try to get across my current state of ignorance in the hope there might be some helpful suggestions out there.

I also need to learn Objective-C, but I suspect using Interface Builder to develop GUI apps will be the more difficult step for me. I have done a lot of C and assembly programming over the years but never any OOP. I recently moved to a Mac Mini from Windows and really like it a lot. On Windows I could never face trying to learn Visual Studio and C++ etc. I am now pretty determined to learn how to produce GUI apps on the Mac but have only been at it seriously for a few weeks. (At age 67 I am a slow learner!)

I have been browsing for examples and tutorials and stepping through a number of things. Most examples and tutorials I have found are from older versions of Xcode and too many are for IOS rather than for OS-X.

I have the Fifth Edition of Programming in Objective-C and have on order the 4th Edition Hillegass book Cocoa Programming for Mac OS X. The Objective-C book has very little Xcode information and I hope the Hillegass book might be helpful in that area.

I have a specific project in mind that I think will be useful to help me get into both Objective-C and Xcode in more detail once I get past the initial "brick wall" where I am currently stuck. I will try to describe my goal, but my terminology will probably be pretty poor.

This project will have two text view objects, one to type characters into and one to display information in. I need to be "first responder" (?) so I can receive and process keyDown events and take actions by displaying something in the second text view object.

I have found an example Xcode project that is very similar to what I have in mind: http://hayne.net/MacDev/TestKeyDownEvent/

but it comes from Xcode version 2.4 and I am unable to "translate" it sufficiently to duplicate the function under Xcode 4.6.2 with AppDelegate etc.

I have gone through the Apple Getting Started tutorial and mechanically followed the steps to drag from the XIB objects to the AppDelegate.h file and set up the Actions and Outlets etc. but with very little understanding.

If anyone can provide links to other tutorials, references etc. I will be very appreciative. An example project, built with Xcode 4.6.2 that responds to each typed character and takes some action would probably be my ideal resource since I think I could then experiment and use Xcode until I generate files with the same content and in the process hopefully come to understand the fundamentals. I have not yet found anything of this nature.

My specific target project involves controlling and communicating with an external device using a USB serial port and this library: http://blog.andrewmadsen.com/

I have run the example project and it works well, but I have a long way to go before I am ready to integrate it into my own project.

Thanks.
W5UXH is offline   0 Reply With Quote
Old Apr 24, 2013, 11:56 PM   #2
larswik
macrumors 65816
 
Join Date: Sep 2006
If you have C under your belt and have a good understanding of that then stepping in to OOP will be easier. I have written a couple programs on the Mac and have a few apps in the app store. There is not a big difference, in my opinion in the 2.

When I started to learn programming I started with Programming in Objective-C. I found it to be hard to understand and stepped back and learned C first. I was then able to get into Object C but it was still a struggle learning the concepts.

Start with simple tutorial in the book and redo the tutorials your own way. I think if you try and start with the project you will get lost, start with the basics. All the books will use xcode so you will learn that as you go to as you go a long.

It took me 2 years from starting with C and then to objective C before I had an app in the app store. I would also consider learning ios since there is SO MUCH stuff out there to learn from. Then it becomes easy to step into making Mac apps. The concepts and code are almost the same from what I have experienced.

But I would also stay away from any GUI to start, that is just another thing you will need to learn. I should also mention that when I was learning it was over a year until I made my first GUI. I wanted to get a good understanding of Objective C.

This is a good book: http://www.bignerdranch.com/book/obj...rd_ranch_guide

Also what helped me is to see videos and follow along. Lynda.com has good references too.

Lynda's videos: http://www.lynda.com/Xcode-4-tutoria...Fa9cQgod-jkA5A

This is of course is just my 2 cents and how I started learning.
__________________
I know more than yesterday.
Lars
larswik is offline   0 Reply With Quote
Old Apr 25, 2013, 08:03 AM   #3
W5UXH
Thread Starter
macrumors newbie
 
Join Date: Dec 2012
I appreciate your comments Lars. I had not found the Lynda videos. I just watched the first part giving some Objective-C history. I will definitely start the trial and see how it goes.

Last night I did find one of the Mac Developer tutorials (TextViewDelegate) that looks like it is close to the nature of the example I am looking for. It responds to key events and takes an action in a very small program. So I will be trying to dig into that also as I continue studying.

Thanks.

Chuck

Quote:
Originally Posted by larswik View Post
This is of course is just my 2 cents and how I started learning.
W5UXH is offline   0 Reply With Quote
Old Apr 25, 2013, 10:25 AM   #4
iphonedude2008
macrumors regular
 
Join Date: Nov 2009
Location: Irvine, CA
I would suggest against using interface builder at least while you are still learning. It limits your knowledge of what is actually going on which in turn makes it harder for you to solve problems and make good looking a GUI. Animation is also easier when you do everything in code. O
iphonedude2008 is offline   0 Reply With Quote
Old Apr 25, 2013, 10:47 AM   #5
W5UXH
Thread Starter
macrumors newbie
 
Join Date: Dec 2012
OK, that is two votes for staying away from IB for now. I am not sure if the way to do that is to use a terminal window and the CLANG compiler, or to use Xcode and a Command Line Tool application with the Foundation type?

Quote:
Originally Posted by iphonedude2008 View Post
I would suggest against using interface builder at least while you are still learning.
W5UXH is offline   0 Reply With Quote
Old Apr 25, 2013, 12:52 PM   #6
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Quote:
Originally Posted by W5UXH View Post
OK, that is two votes for staying away from IB for now. I am not sure if the way to do that is to use a terminal window and the CLANG compiler, or to use Xcode and a Command Line Tool application with the Foundation type?
No, it would entail instantiating your views in code and using methods like addSubview: to embed those new views in existing views.
ArtOfWarfare is offline   0 Reply With Quote
Old Apr 26, 2013, 12:04 AM   #7
iphonedude2008
macrumors regular
 
Join Date: Nov 2009
Location: Irvine, CA
Quote:
Originally Posted by ArtOfWarfare View Post
No, it would entail instantiating your views in code and using methods like addSubview: to embed those new views in existing views.
Exactly. Although your code will be full of those annoying cgrectmake functions and addsubviews, you will definitely have a better understanding of ios and osx programming. It is also easier to support many devices that way.
iphonedude2008 is offline   0 Reply With Quote
Old Apr 26, 2013, 12:38 AM   #8
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Quote:
Originally Posted by iphonedude2008 View Post
Exactly. Although your code will be full of those annoying cgrectmake functions and addsubviews, you will definitely have a better understanding of ios and osx programming. It is also easier to support many devices that way.
You're probably putting those functions in the wrong file if you're finding them annoying...
__________________
Don't tell me Macs don't last: 2007 iMac, 2007 Mac Mini, 2008 MacBook Air, all Vintage.
(iMac obsoletion: April 28, 2015, MBA: October 14, 2015, Mac Mini: March 9, 2016)
ArtOfWarfare is offline   0 Reply With Quote
Old Apr 26, 2013, 10:08 AM   #9
iphonedude2008
macrumors regular
 
Join Date: Nov 2009
Location: Irvine, CA
What I mean is that it is annoying the time it takes to get the views in the right place, especially when the view has a transform or you are animating it.
iphonedude2008 is offline   0 Reply With Quote
Old Apr 26, 2013, 10:12 AM   #10
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by iphonedude2008 View Post
What I mean is that it is annoying the time it takes to get the views in the right place, especially when the view has a transform or you are animating it.
The creators of Interface Builder probably found them annoying too!
__________________
dejo is offline   0 Reply With Quote
Old Apr 26, 2013, 11:38 AM   #11
iphonedude2008
macrumors regular
 
Join Date: Nov 2009
Location: Irvine, CA
Quote:
Originally Posted by dejo View Post
The creators of Interface Builder probably found them annoying too!
Exactly. I wish interface builder actually generated code instead of an XML file. It would be much faster. That's why I code my views.
iphonedude2008 is offline   0 Reply With Quote
Old Apr 26, 2013, 01:16 PM   #12
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by iphonedude2008 View Post
Exactly. I wish interface builder actually generated code instead of an XML file. It would be much faster. That's why I code my views.
It would then be impossible to replace a nib without recompiling.

Honestly, I've never noticed any big delays loading nib files, so I don't think creating interfaces in code is that much faster than loading a nib. Or did you mean "faster to create" rather than "faster to load at runtime"?
chown33 is offline   0 Reply With Quote
Old Apr 26, 2013, 03:16 PM   #13
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by chown33 View Post
Or did you mean "faster to create" rather than "faster to load at runtime"?
If it's the former, I would disagree. I find it way faster to layout the UI in IB than hand-coding it.
__________________
dejo is offline   0 Reply With Quote
Old Apr 26, 2013, 04:48 PM   #14
iphonedude2008
macrumors regular
 
Join Date: Nov 2009
Location: Irvine, CA
Quote:
Originally Posted by dejo View Post
If it's the former, I would disagree. I find it way faster to layout the UI in IB than hand-coding it.
It is faster to lay out, but I like the customization and control you have over coded views. Especially when making custom views.
iphonedude2008 is offline   0 Reply With Quote
Old Apr 26, 2013, 10:20 PM   #15
iphonedude2008
macrumors regular
 
Join Date: Nov 2009
Location: Irvine, CA
Quote:
Originally Posted by chown33 View Post
It would then be impossible to replace a nib without recompiling.

Honestly, I've never noticed any big delays loading nib files, so I don't think creating interfaces in code is that much faster than loading a nib. Or did you mean "faster to create" rather than "faster to load at runtime"?
I have never had any start time in my apps, even when setting up complex layouts, loading complicated files, and doing 1000's calculations all before the app loads. Or maybe I'm just really good at multithreading.
iphonedude2008 is offline   0 Reply With Quote
Old Apr 27, 2013, 01:24 PM   #16
Madd the Sane
macrumors 6502
 
Join Date: Nov 2010
Location: Utah
Quote:
Originally Posted by iphonedude2008 View Post
It is faster to lay out, but I like the customization and control you have over coded views. Especially when making custom views.
As for custom views: if its a subclass of only NSView, you can put an NSView in the window, then change the class to your custom class. If you have a subclass of another view, do the same thing with the superclass then set the class to the subclass. However, on both cases, you can't change subclass-only parameters: you would have to do it on the viewDidLoad in the window controller.

Interface Builder (before it merged with Xcode) allowed the creation of custom views and editing their values via IB plug-ins. However, this functionality was lost in the move to Xcode 4 (IB wasn't garbage collected, while Xcode is) hopefully the move to ARC will mark the return of Interface Builder plug-ins.
Madd the Sane is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
I need help learning xcode Pajamaxllama iPhone/iPad Programming 14 Nov 20, 2013 02:07 PM
What is a zeitgeist? Need examples rockyroad55 Community Discussion 14 Sep 8, 2013 10:02 PM
AppleScript examples I can compile? 2012Tony2012 Mac Programming 4 Dec 21, 2012 08:04 PM
Interested in learning Obj-C/Xcode what are some good resources? hugodrax Mac Programming 3 Nov 10, 2012 09:07 PM
Recommendations for learning Xcode and Git Greencardman iPhone/iPad Programming 6 Oct 21, 2012 01:51 PM

Forum Jump

All times are GMT -5. The time now is 01:06 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC