Are Foundation and Cocoa Frameworks mutually exclusive?

Discussion in 'Mac Programming' started by MorphingDragon, Feb 17, 2010.

  1. MorphingDragon macrumors 603

    MorphingDragon

    Joined:
    Mar 27, 2009
    Location:
    The World Inbetween
    #1
    This is just a bit of forethought

    I've just about gone through the Obj-C part of SK twice now (Didn't completely understand some of the material) book but I also have Aaron Hillegass' book. My ultimate goal is to do GUI based work which is why I bought Aaron's book (I can see myself doing some CLI programs) but read SK's Obj-C book on recommendation because I didn't know C.

    Should I do the Foundation Framework part of the book anyway? Could I use the Foundation Framework and Cocoa together for any arbitrary reason and it wouldn't cause problems?

    ---

    In chapter 13 it has information on the underlying features of C, if I do this chapter would I essentially "know" C? As I'm very interested in Operating System Development. :)
     
  2. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #2
    The Foundation framework is the basis of everything in Cocoa. There is no Cocoa without Foundation.
     
  3. MorphingDragon thread starter macrumors 603

    MorphingDragon

    Joined:
    Mar 27, 2009
    Location:
    The World Inbetween
    #3
    The article I was reading made it sound like they were completely different things.

    Nice to know. :)
     
  4. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #4
    Which article?
     
  5. MorphingDragon thread starter macrumors 603

    MorphingDragon

    Joined:
    Mar 27, 2009
    Location:
    The World Inbetween
    #5
    Some opensource article, I'll go through my history and see if I can find it.
     
  6. Krevnik macrumors 68040

    Krevnik

    Joined:
    Sep 8, 2003
    #6
    And if you create a Cocoa project, you will notice that both frameworks are already included to be linked against your code. :)
     
  7. autorelease macrumors regular

    Joined:
    Oct 13, 2008
    Location:
    Achewood, CA
    #7
    Foundation is the framework that provides all the non-GUI classes; data structures (NSArray, NSDictionary, etc.), networking stuff (NSURL, NSConnection, etc.), files (NSFileManager, etc.), threads, run loops, timers, etc. It's on the Mac and the iPhone.

    Cocoa is the framework that provides all the GUI widgets. It's Mac only. The iPhone version is called Cocoa Touch. Cocoa and Cocoa Touch are built upon the Foundation framework. As gnasher729 says, there is no Cocoa without Foundation.

    I believe it's possible to write a command-line Objective-C app that uses only Foundation and not Cocoa, but I've never tried it.

    And what's the difference between "Foundation" and "Core Foundation"? Core Foundation is the plain C API that provides most of the same functionality as the (Objective-C) Foundation framework. Most Foundation and Core Foundation data structures (ex. CFArray and NSArray) are interchangeable due to "toll-free bridging."
     
  8. HiRez macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #8
    I thought Cocoa encapsulated both Foundation and AppKit (the desktop UI APIs), and Cocoa Touch encapsulated Foundation and UIKit. In other words, that Cocoa is not just the UI stuff, but the whole thing.
     
  9. Catfish_Man macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #9
    HiRez is correct. There are also a few classes that are implemented in Foundation but have categories extending them in AppKit (NSAttributedString for example).
     
  10. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #10
    It's definitely possible, I've done it many times :)
     
  11. autorelease macrumors regular

    Joined:
    Oct 13, 2008
    Location:
    Achewood, CA
    #11
    That's right, I should have been more specific.
     
  12. perrien macrumors newbie

    Joined:
    Apr 26, 2008
    #12
    Actually, most of my projects start out as Foundation. The M part of MVC usually won't have any Cocoa stuff in it. Only after the model is working fine do I start adding the second layer of complexity that is the GUI.

    Ashley
     

Share This Page