Draggable objects in Cocoa - objective-c

I am completely new to objective c and have an quite ambitious project I want to create.
One of the things I'll need to do is have a drawing layer, where I can have a circle in the middle, and be able to drag other circles near it to attach them, and then be able to move them around, changing their position around the initial circle.
I know this may sound vague, but its the best way I can explain it.
Could anyone give me some pointers as to how this could be achieved, or a good reference where I could learn how to do it?
Many thanks for any help you can provide.

There are two protocols that you should look at: NSDraggingDestination and NSDraggingSource.

Objective-C is a language that can be used for developing command-line applications, iOS applications, desktop Mac applications and other beasts. The language itself does not handle graphics, that is left to the higher layers. If you want to develop for iOS or Mac, this higher layer is called Cocoa.
To develop your application you’ll need to get familiar with Xcode, Cocoa and maybe a bit of Quartz 2D. Go to the Apple Developer Website and start looking there, the documentation is quite good. The code samples are a bit hairy sometimes, but they will get you started.

Related

Use Webcam to Track User's Finger Location

I have a project just starting up that requires the kind of expertise I have none of (yet!). Basically, I want to be able to use the user's webcam to track the position of their index finger, and make a particular graphic follow their finger around, including scaling and rotating (side to side of course, not up and down).
As I said, this requires the kind of expertise I have very little of - my experience consists mostly of PHP and some Javascript. Obviously I'm not expecting anyone to solve this for me, but if anyone was able to direct me to a library or piece of software that could get me started, I'd appreciate it.
Cross compatibility is of course always preferred but not always possible.
Thanks a lot!
I suggest you to start reading about OpenCV
OpenCV (Open Source Computer Vision) is a library of programming functions mainly aimed at real-time computer vision, developed by Intel Russia research center in Nizhny Novgorod, and now supported by Willow Garage and Itseez.1 It is free for use under the open-source BSD license. The library is cross-platform. It focuses mainly on real-time image processing.
But first, as PHP and JavaScript are mainly used for web development, you should start reading about a programming language which is supported by OpenCV like C, C++, Java, Python or even C# (using EmguCV) etc.
Also, here are some nice tutorials to get you started with hand gestures recognition using OpenCV. Link
Good luck!

Creating a simple, single-view Quartz app

I'm an Objective-C newbie. Most of my experience is in Java. Also, I've never really used Xcode before and so I'm pretty new at that as well.
I'm trying to create a simple, single-view Quartz OS X app (not iOS) to display agent-modeling simulations. The graphics are pretty simple; just colored squares and grids. I have been looking at Quartz tutorials and I can see how I could accomplish this (as far as drawing things are concerned). What I can't find is an example that tells me how to tie it all together. What do I put in AppDelegate? Do I need a WindowController? How do I link that up with AppDelegate? I got as far as creating a Quartz Composer View in Interface Builder for my app, but I have no idea where to go from there.
As I mentioned before, I've looked for numerous tutorials but there is nothing that I can find that gives me information as far as linking everything together.
You should visit this web page before you do anything else. It will show you how a Cocoa application is structured and where the appropriate entry points are to place your code.
While the entire article merits reading, visit the section "Entry and Exit Points," which best addresses your particular questions.

What comes after learning objective-c for programming an ios device?

It appears the language is the same for either device ios or mac os on a mbp, but if I learn Objective-C in a tutorial, won't I also need to learn cocoa or cocoa touch to program effectively?
I'm not sure how to start on my path of learning to program an ios device. I know I need to learn objective-c and that appears to work on all apple products. Then do I move to cocoa touch for ipad and iphone? What comes after objective-c?
The type of project is akin to a web app but native objective-c app instead. Have ui, buttons, the app hits some back end location, returns data, I put it on that same ui. Only, as stated, use objective-c and whatever framework and library to do it (that's my dilemma. I dont know what to do next after objective-c).
thanks.
Cocoa and Objective-c go hand in hand. For getting started, I would suggest going over some old WWDC footage and following some of the examples there.
As far as Cocoa and Cocoa touch are concerned, they are very similar in many aspects, same name conventions, similar structure, etc. Learn one, and you can easily pick up the other.
#craig adds:
I would further this answer by also mentioning that Objective-C is a programming language, while Cocoa/Cocoa Touch are collections of frameworks that are provided by Apple, and used by developers to add functionality to their programs. (Which are written in Objective-C.) The Cocoa frameworks contain various UI components like buttons, table views, sliders, etc. in addition to various fundamental classes like NSString and other text- and graphics-based APIs
I started my learning by watching thenewboston's xcode tutorials:
you can begin with this one
Good luck :)
I prefer books for some strange reason and I found that the Apress series of IOS development is really good. The book goes through developing iPhone and iPad apps using all kinds of Cocoa libraries. There's a lot of good books out there on the subject; I would go find one that looks like it would suit your needs.

Augmented reality in mono touch

I'm developing a typical "Windows GUI" based app for iPhone using MONO technologies. I need to add a little AR based functionality to it. It is just about opening up the camera, and showing information to the user regarding nearby businesses.
How can I do this using mono?
Of course it is possible. I have created a project and works very nice. It is quite complicated and I would need three pages to explain it and, the time to do it which I do not have.
In general, you need to look into:
CLLocationManager for location and
compass.
MapKit, if you want to provide
reverse geocoding information.
Implement an overlay view over the
UIImagePickerController which will
act as your canvas.
And of course, drawing.
I hope these guidelines will get you started.

sample mac Firefox Plugins?

I'm trying to re-write an old image-viewing plugin for the mac. The old version uses QuickDraw (I said it was old) and resources (really really old) and so it doesn't work in Firefox 3.6 (which is why I'm re-writing it)
I know some Objective C, and so I figure I'm going co re-write this in that using new-fangled Mac routines and nibs, etc. However, I don't know how to start. I've got the BasicPlugin example that comes with mozilla source, so I know how to create a plugin with entrypoints, etc. However, I don't know how to create the nib, and how to interface Obj-C with the entrypoints, etc.
Does anyone know of a more advanced sample for mac than BasicPlugin.bundle? (Preferably simple enough that I can just look at it and understand it...)
thanks.
Sadly i don't really know of any good "intermediate" example. However, integrating Obj-C isn't that difficult. Thus, following is a short overview of what needs to be done.
You can use Obj-C and C/C++-sources in the same project, its just recommendable to keep them seperated to some extent. This can for example be done by letting the source file with the entry-points and other NPAPI-interfacing stay plain C or C++ files and e.g. forward calls into the plugin from there.
Opaque pointers help to keep a clean seperation, see e.g. here.
The main changes to your plugin include switching to different drawing and event models. These have to be negotiated in NPP_New(), here is an example for the drawing model. When using Cocoa and to support 64bit enviroments, you need to use the Cocoa event model.
To draw UI elements you should be able to use a NSGraphicsContext from the CGContextRef and then draw an NSView in the context. See also the details provided in this post and its follow-ups.