Professional Web Applications Themes

Cocoa Newbie Suddenly Disillusioned - Mac Programming

Hi. I just started Cocoa - like a couple weeks ago - and fell in lust. However, the honeymoon seems to be over. I'm starting to come across more areas where there don't seem to be Cocoa equivalents to Carbon APIs. Naturally I understand it's a very different way of working/thinking. There are some things that I can't seem to easily resolve. For example, I had an app (Carbon, of course) that had a moderately low-level file search & filter class that gathered images that I edited thru QuickTIme. I was used to buzzing thru FS and PB APIs and ...

  1. #1

    Default Cocoa Newbie Suddenly Disillusioned

    Hi. I just started Cocoa - like a couple weeks ago - and fell in lust.
    However, the honeymoon seems to be over.

    I'm starting to come across more areas where there don't seem to be
    Cocoa equivalents to Carbon APIs. Naturally I understand it's a very
    different way of working/thinking. There are some things that I can't
    seem to easily resolve.

    For example, I had an app (Carbon, of course) that had a moderately
    low-level file search & filter class that gathered images that I edited
    thru QuickTIme. I was used to buzzing thru FS and PB APIs and doing
    file stuff very quickly. I feel that with Cocoa I'm so far removed from
    the file system that I can't te this kind of thing. The
    alternatives seem to be to use either the high-level Cocoa stuff, or
    else use std APIs (which seem inorganic when messing with FS Catalog
    stuff). Or is it normal to make Carbon shlbs to use from Cocoa apps?
    There's all this really powerful new Cocoa stuff, to be sure, but some
    things seem missing.

    This is a y example, because I'm taking a break from programming,
    and can't think of anything more complex than the "Smallville" episode
    on tonite, but I hope the idea gets across.
    --
    No sig, no neuroses

    Mikey Guest

  2. #2

    Default Re: Cocoa Newbie Suddenly Disillusioned

    Mikey wrote: 

    You can use Carbon stuff from Cocoa pretty easily - just add
    Carbon.framework to your project and you should be all set.

    <http://developer.apple.com/doentation/Cocoa/Conceptual/CarbonCocoaDoc/>
    endian Guest

  3. #3

    Default Re: Cocoa Newbie Suddenly Disillusioned

    Mikey <net> wrote:
     

    I don't know what you mean about shlbs, but it is quite common to use
    Carbon calls here and there in a Cocoa app (esp for low-level file stuff
    such as you're doing). So? You get a great app framework plus all your
    old Carbon code just goes right on working. Why is that bad? m.

    --
    matt neuburg, phd = com, http://www.tidbits.com/matt/
    AppleScript: The Definitive Guide
    http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
    Read TidBITS! It's free and smart. http://www.tidbits.com
    matt Guest

  4. #4

    Default Re: Cocoa Newbie Suddenly Disillusioned

    Mikey wrote: 

    Can you be more specific? 

    NSDirectoryEnumerator didn't do what you want?

    -jcr
    John Guest

  5. #5

    Default Re: Cocoa Newbie Suddenly Disillusioned

    On Wed, 5 May 2004, Mikey wrote:
     
    [snip]

    The other posters have covered most of the relevant points. However, I
    want to point out the CoreFoundation/Foundation bridging, since nobody's
    brought it up yet and it can be extremely useful when interacting with
    some areas of Carbon. Most basic Foundation objects (NSString, NSArray,
    NSSet, NSDictionary, etc.) are toll-free bridged to their CoreFoundation
    counterparts. What that means is that any time you have a function that
    takes a CFStringRef, you can pass it an NSString, and if it returns a
    CFStringRef you can treat it like an NSString, complete with
    square-bracket method invocations. This lets you keep more of your code in
    ObjC when interacting with CoreFoundation and the parts of Carbon that use
    CF objects.
    Michael Guest

  6. #6

    Default Re: Cocoa Newbie Suddenly Disillusioned

    On 2004-05-05 22:02:52 -0400, com (matt neuburg) said:
     
    >
    > I don't know what you mean about shlbs, but it is quite common to use[/ref]

    I mean shared libraries, but I guess now it would by a framework.
     

    So it's not considered disgusting/heinous/bad form/whatever to include
    Carbon APIs?

    --
    No sig, no neuroses

    Mikey Guest

  7. #7

    Default Re: Cocoa Newbie Suddenly Disillusioned

    On 2004-05-06 06:42:02 -0400, Michael Ash <com> said:
     
    > [snip]
    >
    > The other posters have covered most of the relevant points. However, I
    > want to point out the CoreFoundation/Foundation bridging, since nobody's
    > brought it up yet and it can be extremely useful when interacting with
    > some areas of Carbon. Most basic Foundation objects (NSString, NSArray,
    > NSSet, NSDictionary, etc.) are toll-free bridged to their CoreFoundation
    > counterparts. What that means is that any time you have a function that
    > takes a CFStringRef, you can pass it an NSString, and if it returns a
    > CFStringRef you can treat it like an NSString, complete with
    > square-bracket method invocations. This lets you keep more of your code in
    > ObjC when interacting with CoreFoundation and the parts of Carbon that use
    > CF objects.[/ref]

    Yes, okay, this I get. I inteded to use CF stuff throughout. So it's
    not so unusual to mix Carbon in? Sounds good.
    --
    No sig, no neuroses

    Mikey Guest

  8. #8

    Default Re: Cocoa Newbie Suddenly Disillusioned

    dans l'article 2004050708505975249%exceptionsTakeThisOutDudeeart hlinknet,
    Mikey à net a écrit le 7/05/04 14:50:
     
    >>
    >> I don't know what you mean about shlbs, but it is quite common to use[/ref]
    >
    > I mean shared libraries, but I guess now it would by a framework.

    >
    > So it's not considered disgusting/heinous/bad form/whatever to include
    > Carbon APIs?[/ref]

    Certainly not, since it's-almost- mandatory.

    Eric

    Eric Guest

  9. #9

    Default Re: Cocoa Newbie Suddenly Disillusioned

    In article
    <2004050708524150073%exceptionsTakeThisOutDudeear thlinknet>, Mikey
    <net> wrote:
     

    It is good and as Eric says it is absolutely necessary for some things
    including a lot of low level file stuff, most QuickTime functionality,
    etc.

    But one warning; don't jump to the conclusion that you need to need to
    resort to Carbon right off the bat. For a lot of newcomers,
    particularly those coming from a Carbon background, it is easy to
    overlook capacities already built into Cocoa.

    --
    James P. Spencer
    Rochester, MN

    "Badges?? We don't need no stinkin badges!"
    James Guest

  10. #10

    Default Re: Cocoa Newbie Suddenly Disillusioned

    In article
    <2004050518011675249%exceptionsTakeThisOutDudeear thlinknet>,
    Mikey <net> wrote:
     

    In most cases, such things are simply hidden a little. E.g. when
    listing files, getting at their type and creator codes is done by
    fishing an NSNumber out of the attributes dictionary for the file.
     

    Most of the File Manager is ted either in NSWorkspace or
    NSFileManager, or in some of the other classes in the form of
    initWithContentsOfFile: or writeToFile: methods. If you don't need
    backwards compatibility with Classic or Carbon applications, that is
    usually enough.

    If you do need more, some people have written nice wrapper classes
    around the Carbon code that will let you stay beautifully in Cocoa land,
    most notably BDAlias, NDResourceFork and PTHotKey. If you can't locate
    any useful wrapper classes (the Object Library at http://www.cocoadev.com
    is a good place to look for ready-made classes), chances are they aren't
    necessary.

    But if that isn't the case, remember to *always* write a Cocoa wrapper
    around Carbon code you use. You'll kick yourself later when a better API
    arrives and you have to remove Carbon dependencies all over the place,
    and if another Cocoa developer ever has to work with your code, they'll
    be grateful for not having to learn Carbon. Besides, you can also make
    it available to others and thus save them work, and give back to people
    like Nathan Day who have done similarly.
     

    The high-level Cocoa stuff is pretty decent, and should usually work
    just fine for you. I'd always suggest you try the built-in stuff first.
    You can always switch out an NSDirectoryEnumerator with a hand-grown
    class of your own that accepts the same messages but uses
    FSCatalogSearch internally or whatever.
     

    No shared libraries or external frameworks needed. You just add
    Carbon.framework to your project file and include Carbon/Carbon.h, and
    you can call the Carbon APIs right out of Cocoa code should you need to.
    Just be careful there. There is really no reason to do any GUI stuff
    with Carbon in a Cocoa app. You should only use that for low-level calls.
     

    Well, often they're just not that obvious. Cocoa was designed by people
    that were a lot smarter than most of us here (definitely smarter than
    me), and usually there's a valid reason for some of the seemingly weird
    things. So, if you have any particular problem and Cocoa doesn't seem to
    do it, just ask here, or on Apple's Cocoa-Dev mailing list. Chances are
    that either someone will tell you what you overlooked, or somebody's
    already got a class you can just plug in. At least that's been my
    experience so far.
     

    Chloe or Lana? ;-)

    Cheers,
    -- M. Uli Kusterer
    http://www.zathras.de
    Uli Guest

Similar Threads

  1. C++ in cocoa
    By Robert in forum Mac Programming
    Replies: 6
    Last Post: February 26th, 07:19 PM
  2. Considering Cocoa Books
    By David in forum Mac Programming
    Replies: 10
    Last Post: January 31st, 09:54 PM
  3. Newbie: Background Processing (Cocoa)
    By ivo in forum Mac Programming
    Replies: 3
    Last Post: January 31st, 02:24 AM
  4. Cocoa newbie -- help with multiple windows
    By Larry Fransson in forum Mac Programming
    Replies: 11
    Last Post: August 15th, 07:42 AM
  5. newbie cocoa file reading/writing files
    By Richard Humiston in forum Mac Programming
    Replies: 1
    Last Post: July 21st, 02:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139