Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Ender.uNF posted:

Well F-me, I just accidentally refreshed and lost a huge reply I wrote up... but basically they tell you how to do this in the article you linked. You just need to identify what your key field(s) are... in their example, they are using employeeID. The fact that the DB results and server results are both sorted in order allows you to use two indexes with a loop and walk forward, increasing the db list index only if the matching record is found in the server list, otherwise add a new record to the context and continue with the next pass until you reach the end of the server list. You just need to compare the dates as you go. If you can provide more detail I might be able to offer more help.


You can also check out http://restkit.org/. I haven't used it yet but it is supposed to be able to grab stuff from a REST web service and stuff it into CoreData (using it as an offline cache and updating as appropriate).

Thanks for the reply. I saw their looping structure, but that comment I quoted from the article made is seem like there was a Magic Line of Code™ where I set a single predicate on my new objects and when I save, dupes dont' happen.

I'll probably take you up on your offer of more detail when i get closer to implementation, righ tnow just thinking through it all.

Adbot
ADBOT LOVES YOU

lord funk
Feb 16, 2004

Right now I'm saving file data for my app as NSData (as in, writing a save file to disk). This has served its basic function, but I'm looking into setting up a sharing system where users can upload their files to a server, then search and download other users' stuff in the app.

My question is: what is the proper format for files like this, and how do you store the necessary metadata (version number, attributes, creator's name) for a server backend to understand?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Well, you can put the metadata in your saved file, maybe as a header, and the server can simply read the first few bytes to figure out what it's looking at while you upload it. So long as you make sure to specify the file format well (endianness etc.) it couldn't possibly matter what the server's running, it'll all come out fine.

Or, when you send the file to the server, include that metadata along with it, e.g. as form-encoded key-value pairs in an HTTP POST.

How do you store that metadata in the app right now? Some central database?

lord funk
Feb 16, 2004

pokeyman posted:

Or, when you send the file to the server, include that metadata along with it, e.g. as form-encoded key-value pairs in an HTTP POST.
This is a much better idea than what I originally had in mind.

quote:

How do you store that metadata in the app right now? Some central database?
Right now the data is stored in key-value pairs inside the files themselves. I'm just now starting to look at alternatives.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Then I'd say it depends on the format of the files. If it's something convenient like JSON, just throw it at the server and have the server parse out the metadata. If it's a binary format or plist, I'd probably parse out the metadata client-side and send it up along with the intact file, to save myself from maintaining two different parsers. (Unless your server's written in C or Objective-C or whatever and you can reuse that code.)

Of course, if we're talking 2kb files and fewer than 1,000 simultaneous uploads, none of this matters and you can pretty well do whatever you like.

lord funk
Feb 16, 2004

pokeyman posted:

Of course, if we're talking 2kb files and fewer than 1,000 simultaneous uploads, none of this matters and you can pretty well do whatever you like.

Then I should be :coal:. I'm meeting with someone to discuss the server backend tomorrow, but now I have a better idea of what I'm getting into.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
So after banging my head against my app and documentation and forums I've come away with a much better understanding of viewControllers and how they all relate to the rootViewController and was able to pretty much fix my rotation problem! Yay! :v:


However I'm still a little stuck on another small detail involving orientation. It seems that UIDeviceOrientation only returns a value after you rotate the device once so if you start the app in portrait or landscape and try to check orientation for any reason you'll receive a NULL value. The same goes for checking [self interfaceOrientation] from the rootViewController.

I've seen some forums posts saying that in order to check orientation prior to actually rotating the device you need to rely on accelerometer settings. Is that really the case?


e: huh, apparently [UIApplication sharedApplication].statusBarOrientation returns orientation values before you actually change orientation but nothing else does. that seems...odd

e2: so it looks like UIDeviceOrientation and statusBarOrientation can easily be out of sync at different times if you're rotating and pressing things with wild abandon so in order for the user experience to not be a mess the best thing to do is to use UIDeviceOrientation when possible but if it's NULL then fall back on statusBarOrientation

:science: i hope

Yodzilla fucked around with this message at 16:50 on Jan 29, 2012

Doc Block
Apr 15, 2003
Fun Shoe
The app I'm working on right now checks at startup (root view controller's viewDidLoad) to see what the device oerientation is, and it works fine. Once I'm at my computer I'll check and see what I did to make that work (haven't looked at that part of the code in months, but AFAIK I had it check the status bar orientation).

edit: yep, it just does

code:
UIInterfaceOrientation orient = [[UIApplication sharedApplication] statusBarOrientation];
if(orient == UIInterfaceOrientationPortrait ||
   orient == UIInterfaceOrientationPortraitUpsideDown) {
	// portrait stuff
} else {
	// landscape stuff
}

Doc Block fucked around with this message at 19:23 on Jan 29, 2012

lord funk
Feb 16, 2004

Yeah, the statusBarOrientation is the only way to go.

code:
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (UIInterfaceOrientationIsPortrait(orientation)) {
              //
} else {
              //
}
You're supposed to use the delegate methods (-willAnimateRotationToInterfaceOrientation, -didRotate...), but there are just times when you need to check and you aren't trying to rotate. While this is now the 'standard,' it always felt a little hacky.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

lord funk posted:

Then I should be :coal:. I'm meeting with someone to discuss the server backend tomorrow, but now I have a better idea of what I'm getting into.

The best way these days seems to be JSON data; the frameworks for building and parsing JSON on iOS have gotten relatively fast and stuff like restkit gives you an easy way to send http requests. One of its modes is key-value pairs/plist type stuff. If you already have key-value pairs then it should be trivial.

XML support on iOS is... Less than stellar and anything else is going to be a custom format and a headache.

Just tell whoever is writing it that you want a REST API and you will be good to go.

lord funk
Feb 16, 2004

Ender.uNF posted:

Just tell whoever is writing it that you want a REST API and you will be good to go.
This sounds perfect. JSON + restkit and this might happen way sooner than I expected. Thanks!

HolyJewsus
Jun 26, 2006
Disgruntled By Flashing and Blinking Lights.
Hello, I'm not sure if this is the place, but I'm seeking knowledge or a capable mac os x developer to help me build a wacom plugin for unity3d. Unity allows c++ and objective c plugins which are packaged as bundles to be called from c# scripts within the engine.

http://unity3d.com/support/documentation/Manual/Plugins.html


All I need from the wacom tablet is pressure data.

Failing that approach since it seems nicer, but more difficult:

Another thought I had was to use Event taps and then print these to a text file after extracting the pressure data, this is fine for me as my application is for academic study. (architecture thesis) I can then read the text file back into unity ( got that covered)

I'd be willing to pay for some timely help!

I've looked at the sample wacom code here: http://www.wacomeng.com/mac/index.html and disected the cocoa simple app to the point where I can't understand anymore of what it's doing

(just starting my foray into coding)



mjk39@buffalo.edu

HolyJewsus fucked around with this message at 00:08 on Jan 30, 2012

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Yodzilla posted:

So after banging my head against my app and documentation and forums I've come away with a much better understanding of viewControllers and how they all relate to the rootViewController and was able to pretty much fix my rotation problem! Yay! :v:


However I'm still a little stuck on another small detail involving orientation. It seems that UIDeviceOrientation only returns a value after you rotate the device once so if you start the app in portrait or landscape and try to check orientation for any reason you'll receive a NULL value. The same goes for checking [self interfaceOrientation] from the rootViewController.

I've seen some forums posts saying that in order to check orientation prior to actually rotating the device you need to rely on accelerometer settings. Is that really the case?


e: huh, apparently [UIApplication sharedApplication].statusBarOrientation returns orientation values before you actually change orientation but nothing else does. that seems...odd

e2: so it looks like UIDeviceOrientation and statusBarOrientation can easily be out of sync at different times if you're rotating and pressing things with wild abandon so in order for the user experience to not be a mess the best thing to do is to use UIDeviceOrientation when possible but if it's NULL then fall back on statusBarOrientation

:science: i hope

I assume by UIDeviceOrientation you're checking the orientation property on UIDevice? If so, remember to call the method that's called something like -beginMonitoringDeviceOrientationChanges on the singleton UIDevice instance.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

HolyJewsus posted:

Hello, I'm not sure if this is the place, but I'm seeking knowledge or a capable mac os x developer to help me build a wacom plugin for unity3d.

If nobody accepts your offer, I (and I'm sure others in the thread) would be more than happy to help you out if you get stuck along the way.

Looking quickly over the sample code you mentioned, it looks like the pressure data is built into OS X events.

Take a look at this blog post about Unity plugins in OS X. It's not quite the same, as the post talks about getting trackpad data, but you could probably combine that post with the 'Cocoa Simple' project you linked to.

HolyJewsus
Jun 26, 2006
Disgruntled By Flashing and Blinking Lights.

pokeyman posted:

If nobody accepts your offer, I (and I'm sure others in the thread) would be more than happy to help you out if you get stuck along the way.

Looking quickly over the sample code you mentioned, it looks like the pressure data is built into OS X events.

Take a look at this blog post about Unity plugins in OS X. It's not quite the same, as the post talks about getting trackpad data, but you could probably combine that post with the 'Cocoa Simple' project you linked to.

you sir, made my day.

I'll read that right away.

My basic methodology has been, delete everything in the cocoa simple app until I no longer get pressure data when using the app, or until it doesn't run anymore, then try to figure out what it's doing.

I guess my real confusion comes from how the plugin will get the mouse events that unity receives? and extract the pressure data from there?

also if anyone is interested my work is https://www.archiware.wordpress.com general art dump, but my thesis work is here as well.

HolyJewsus fucked around with this message at 20:06 on Jan 30, 2012

Haud
Dec 6, 2007

World's Worst Interview

BiohazrD posted:

This is sort of what I did. I'm really, really new to XCode/ObjC so could you tell me how I create a NIB? I'm using storyboards, so I don't think they are created normally. Also, I think I probably made this harder to understand because I said "Interface Builder", sorry.

I ended up using initWithIdentifier, which let's me just set an identifier for the view controller in the storyboard, and then create an instance of it as designed in my classes.

I'm new to objective-c too, and while storyboards have been a bit of a mental hurdle for me, the more I use them, the more I like them.

When you want to create a new view, what you do is drag a new ViewController onto the storyboard panel and then create a new objective-C class that inherits UIViewController. At this point, if you click on the viewcontroller in the storyboard and go to its properties, (I think, I forget which section it is since I don't have XCode in front of me), you can set the class of the viewController; set the class to the class name you created in the solutions window, and they should then be linked up, so now you can set the delegate and link up any items on the Storyboard object to the class.

At this point, you have no reason to programmatically create the view (though you can if you wanted to, I suppose) since the storyboard will automatically init the view when it is called. To call (transition) to a new view, what's easiest to do is to control click the button (or whatever object it is that will cause a transition to the new view) and draw a line to the view controller you want it to move to when you tap that button. This will create a segue. Make the segue modal, and the storyboard should automatically create a new instance of that ViewController when you tap that button (in essence, it will call the init method of the viewController).

Now if you want to pass any data from the current view to the new one, then you override the method "-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender". when a segue is about to happen in a storyboard, it calls this method before it unloads the current view and runs any code you have in there. The segue object contains a property called destinationViewController which will be whatever View that you set to be opened. So what you can do is something like

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NewViewController *vc = [segue destinationViewController];
[vc setCarName:[CurrentViewController carName]];
}

So now, when NewViewController is opened, the car name (or whatever) will be set to the value you specified.

This has been a bit of a crash course in storyboard basics, so I hope my rambling answered your question somewhat.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

HolyJewsus posted:

you sir, made my day.

I'll read that right away.

My basic methodology has been, delete everything in the cocoa simple app until I no longer get pressure data when using the app, or until it doesn't run anymore, then try to figure out what it's doing.

I guess my real confusion comes from how the plugin will get the mouse events that unity receives? and extract the pressure data from there?

In the blog post I linked, look at when the plugin gets initialized (SetupTrackingObject). It reaches into the application to find the main window, then finds the content view of the main window, and inserts the plugin itself as the next responder after the view. What this does is cause any events not handled by the main view (such as touchesBegan, touchesEnded, etc.) to fall through to the plugin, giving the plugin a chance to respond to the events. (What it should also do is set the plugin's next responder to the view's old next responder, so the chain isn't broken. What you should also do is call super so the window doesn't stop working.)

The events that NSView listens to are defined on its superclass, NSResponder. Override the methods you're interested in (just like the Cocoa Simple view does) such as -mouseDown: in your plugin, insert your plugin into the responder chain, and see if you get the events coming through. Once you get the events, you should be able to grab their pressure data and call back into your Unity code.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



So if I do this (under ARC):
code:
- (void)awakeFromNib
{
    [someOtherObject setColor:CGColorCreateGenericRGB(0.0f, 0.0f, 1.0f, 0.5f)];
}
I get a complaint from the static analyzer, cause CGColorCreate returns a CF object with a retain count of 1, and I never reference it again in this code path.

The property declaration on someOItherObject looks like this:
code:
@property CGColorRef color;
I've been reading through the memory management docs as well as the ARC docs and I can't really think of a way to do it.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
Well, we can simplify the analysis a bit. CGColorRef is a "CF" type, i.e. not an Objective-C type, and it stays a CF type everywhere in this code snippet. Therefore, ARC is not doing anything here at all. This is one of the unfortunate limitations of ARC right now.

For the same reason, the property does not know that it needs to do retains and releases for the object it's holding on to; it just stashes the pointer away as a bunch of bits. This is true independent of ARC.

Now, your code probably works, because this is probably the only store which ever happens to that property, so setting it to a +1 value has the rough net effect of having it retain that value. However, the color will be leaked unless -[SomeOtherObject dealloc] releases it.

If you want a property of CF type to behave like a property of ObjC type, you have to give it a custom implementation to do the necessary retains and releases.

Probably what you actually want here, though, is to make it a readonly property and have the object's init method set its color ivar directly.

klem_johansen
Jul 11, 2002

[be my e-friend]
I'm working on an app for an event in which the client really wants FourSquare integration. I'm confident that I can set up venues and enable "check-in" to the various spots. However, the client really wants a way to display the user's nearby friends and their last check-in.

I read somewhere that the FourSquare API does not allow for that sort of thing and can only access check-in history for the logged-in user. Is that correct? I'm trying to figure out the best way to do this. Any suggestions?

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



rjmccall posted:

Well, we can simplify the analysis a bit. CGColorRef is a "CF" type, i.e. not an Objective-C type, and it stays a CF type everywhere in this code snippet. Therefore, ARC is not doing anything here at all. This is one of the unfortunate limitations of ARC right now.

For the same reason, the property does not know that it needs to do retains and releases for the object it's holding on to; it just stashes the pointer away as a bunch of bits. This is true independent of ARC.

Now, your code probably works, because this is probably the only store which ever happens to that property, so setting it to a +1 value has the rough net effect of having it retain that value. However, the color will be leaked unless -[SomeOtherObject dealloc] releases it.

If you want a property of CF type to behave like a property of ObjC type, you have to give it a custom implementation to do the necessary retains and releases.

Probably what you actually want here, though, is to make it a readonly property and have the object's init method set its color ivar directly.

Thanks for the input. The awakeFromNib is in another object, which has an IBOutlet pointing to someOtherObject - I don't want to put the line in init, it's meant to be possible to customize the appearance of sOO from outside.

& Yeah, it works, and I figured it was because the retain from CF was holding onto it and nothing else was releasing it, obviously a leak.

So if I make a custom getter/setter pair + take care of the ivar in [someOtherObject dealloc], do I annotate the @property declaration so ARC knows that it's fine to accept a +1 retained CF value? How would I let ARC know that it's fine?

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Carthag posted:

Thanks for the input. The awakeFromNib is in another object, which has an IBOutlet pointing to someOtherObject - I don't want to put the line in init, it's meant to be possible to customize the appearance of sOO from outside.

Okay. Then yeah, you should make a setter.

Carthag posted:

So if I make a custom getter/setter pair + take care of the ivar in [someOtherObject dealloc], do I annotate the @property declaration so ARC knows that it's fine to accept a +1 retained CF value? How would I let ARC know that it's fine?

Well, it's the static analyzer that's complaining, not ARC. ARC doesn't do anything special for CGColorRef.

The convention and best practice for setters is to have them expect an object at +0, which means they need to retain it themselves. Yes, that means there's an unnecessary retain and release. It also means that awakeFromNib would have it balance out its own +1 it after doing the set, which is a pain. Such is life with manual retain/release. It would've been better if the convention for setters had been +1, but then you'd have to enumerate everything that qualifies as a "setter", and it'd be a pain when working with objects that you only had at +0, and it's too late anyway.

If you're sure you want to write a custom setter that expects a +1 CF value, you can give it a custom declaration with the CF_CONSUMED attribute, and that should shut the static analyzer up:
code:
- (void) setColor: (CGColorRef) CF_CONSUMED color;
But other people reading your code, including You From The Future, might be surprised at the apparent imbalance of retain/release.

rjmccall fucked around with this message at 23:33 on Feb 1, 2012

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

rjmccall posted:

The convention for setters is +0. It's better practice to have the setter just retain the new object. Of course, that means that awakeFromNib has to release it after doing the set, which is a pain, but such is life with manual memory management.

A literal game of hot-potato. Who owns this reference? :iiam:

To elaborate, the code invoking the setter should pretend it knows nothing of the setter's internals so the next line after the call to the setter should release. Likewise the setter should assume it must retain the value (and release it when the value is changed, unless the new value is the same reference as the old value in which case don't... Or you can use the pattern of always retaining the param, then release the ivar and assign param to ivar which is less efficient but trivial to get right)

Jeez, manual memory management sucks balls.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Yeah it seems doing extra work to make something behave in a nonstandard way...

I think I'll just have the property be NSColor and then I can do the CF stuff inside someOtherObject hidden from the world outside with retain/release as needed. Either that or I'll have the outside object retain/release before&after it's used sOO (just annoys me that I'll have to keep a reference to it now).

Just seems like there would be a real quick way to just shoot off a CGColorRef like you would an NSObject.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
Pro tip #5712: In Xcode 4, the handy shortcut for adding frameworks seemed to disappear, requiring you to select an existing framework, right-click, open in finder, then drag other frameworks in and be sure to uncheck copy local and pick create references.

Well it turns out if you click on your project, then click on your target, then the Build Phases tab, expand Link Binary with Libraries, then click the "+" in the lower-left Bam! our old friendly framework dialog still exists.



If you find yourself confused about where to look between schemes, project (info? build settings?), targets (also info, build settings, and build phases and build rules), etc... don't feel ashamed. Which one has my pre-build scripts? Where do I go to change the target OS version? To pick my signing key? How do I exclude a file from a certain target? It happens to everyone.

Simulated fucked around with this message at 00:42 on Feb 2, 2012

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Carthag posted:

Just seems like there would be a real quick way to just shoot off a CGColorRef like you would an NSObject.

It's something we're looking at. There are some serious language issues around it, though.

Doc Block
Apr 15, 2003
Fun Shoe

Carthag posted:

Yeah it seems doing extra work to make something behave in a nonstandard way...

I think I'll just have the property be NSColor and then I can do the CF stuff inside someOtherObject hidden from the world outside with retain/release as needed. Either that or I'll have the outside object retain/release before&after it's used sOO (just annoys me that I'll have to keep a reference to it now).

Just seems like there would be a real quick way to just shoot off a CGColorRef like you would an NSObject.

CGColorRef is a pointer to a C struct/whatever, not an Objective-C object. And with C, you must manage your own stuff.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



rjmccall posted:

It's something we're looking at. There are some serious language issues around it, though.

Awesome! ARC is amazing and Objective-C & Cocoa are getting really exciting. :)

lord funk
Feb 16, 2004

Has anyone migrated a pre-ARC project to ARC? Want to give a trip report?

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
Is there anything public yet about the next round of Objective-C improvements?

SheepThrowinBoy
Sep 20, 2003

"Joel, what are these films
supposed to teach us?"

"We're born, we die, & there is
a lot of padding in between."
Summary: Imagine you have a friend who's savvy with computers but has no programming experience. Where and what do you tell him to study if he wakes up one morning determined to be an iOS programmer?

Background: I am an art school graduate who's great with Mac/PC operation but has almost zero coding experience. Once in high school I programmed my TI-89 to do some of my homework for me, which was cool, and more recently I made it through 7 of 10 chapters in Rory Lewis' iPhone and iPad Apps for Beginners before my eyes glazed over and I got totally lost. I fell like I can mimic what's being taught in these books but I want to REALLY understand what I'm doing.

I need more of a foundation, but I don't even know enough to know where to begin. I'd like to start taking classes (preferably online) but I don't even know what classes to take. I started watching Stanford's Winter 2010 App Dev classes on iTunes U but even Alan's introduction was a little over my head. I'm not opposed to taking/paying for actual classes, of course, I just don't know what to look for. The FAQ suggest I learn Python, but for someone with as little experience as I have even that looks intimidating.

I've got the basics of Xcode down and I'm even enrolled in the Apple Dev Program. I've made a few piddly Hello World programs, but I feel like I'm building a house without being able to read blueprints. Now that I know I CAN do it, where do I go to understand WHAT I'm doing?

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



I find the best way to teach myself a new language/environment is to have a set project that I want to do. Something more than a hello world, but not a huge project either. Something that'll challenge you to learn. Right now I'm writing a genealogy app with core data & all the OS X tech I can think of, to get a feel for how it all interoperates. Plus I'm sick of existing genealogy apps, so there's my motivation.

What that project is for you exactly I don't know.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
This very fluffy advice is the best I've got: I suggest you find a project that you're passionate about and is just large enough that you're not totally sure how you'll implement it.

If you can describe something that you know you can do but you don't understand what's going on, feel free to post it and we can try to help further.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

SheepThrowinBoy posted:

I've got the basics of Xcode down and I'm even enrolled in the Apple Dev Program. I've made a few piddly Hello World programs, but I feel like I'm building a house without being able to read blueprints. Now that I know I CAN do it, where do I go to understand WHAT I'm doing?

Do you know C and Objective-C yet? That's probably your first step. I know when I read some iPhone/Mac books 2 years ago I would get lost in all the collection classes (NSArray, NSDictionary), memory management stuf, and the fact that I just didn't know how to use any of the tons of methods all the objects have. poo poo I still feel like I haven't scratched the surface of most of the objects. Robert Clair, Steven Kochan, and Aaron Hillegass all have books out about Objective-C 2.0

Once you've gotten a grasp of the base language, just start trying to write some apps. Simple-seeming stuff like an address book with photos will get your feet wet. Apress makes a couple books that are worth looking through, the Big Nerd Ranch stuff is good but it's more theory than application (not that that is a bad thing)

OHIO
Aug 15, 2005

touchin' algebra

SheepThrowinBoy posted:

Now that I know I CAN do it, where do I go to understand WHAT I'm doing?

There are tons of little things to learn about programming in general and specific to iOS. It can be overwhelming. I'm still learning things (same with everyone else here).

It depends on you and how you learn. But you said you got a Hello world app running? That's great! Try to break it down and understand how it works. Try to come up with specific questions to Google or ask here. One day it will start clicking (or not haha).

xzzy
Mar 5, 2009

I think there's a big difference between "learning to program" and "developing for iOS".

Jumping right into a tightly controlled environment like an iPhone incurs a huge learning curve that may scare off someone who's not really sure what to do.

I'd back off on scope for a little while.. pick up one of the scripting languages that are out there (python is my favorite but there are several to choose from) and make a couple cheesy text based games. This develops a foundation that you can build off and it will make the entire process more tolerable. Eventually you can add graphics into your projects and once you get a grasp of that, the sky's the limit.

HolyJewsus
Jun 26, 2006
Disgruntled By Flashing and Blinking Lights.
Been working on this plugin for wacom, got the trackpad events firing into unity and working, so thats good, still struggling to understand what these two lines are doing, and what my mouseDown void should do similarly to get pressure.



- (void)touchesCancelledWithEvent:(NSEvent *)event
{
float posX = 0.0f;
float posY = 0.0f;

//what is this line doing?//
NSSet *touches = [event touchesMatchingPhase:NSTouchPhaseBegan inView:view];
for (NSTouch *touch in touches)
{
posX = touch.normalizedPosition.x;
posY = touch.normalizedPosition.y;
break;
}

//Call method back
void *args[] = { &posX, &posY };
mono_runtime_invoke(trackPadTouchCanceledMethod, NULL, args, NULL);
}


- (void)mouseDown:(NSEvent *)event
{
float mPressure = 0.0f;
mPressure = [event pressure];

void *args[] ={ &mPressure };
mono_runtime_invoke(mouseDownMethod, NULL, args , NULL);

}
EDIT:
So this is actually working but it only delivers the event when I click on the certain parts of the screen, I figure this is because I'm not calling InView:view, as I get an error that I need a ":". I'm not sure what to declare between the event and the InView.

HolyJewsus fucked around with this message at 22:05 on Feb 2, 2012

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



HolyJewsus posted:

Been working on this plugin for wacom, got the trackpad events firing into unity and working, so thats good, still struggling to understand what these two lines are doing, and what my mouseDown void should do similarly to get pressure.



- (void)touchesCancelledWithEvent:(NSEvent *)event
{
float posX = 0.0f;
float posY = 0.0f;

//what is this line doing?//
NSSet *touches = [event touchesMatchingPhase:NSTouchPhaseBegan inView:view];
for (NSTouch *touch in touches)
{
posX = touch.normalizedPosition.x;
posY = touch.normalizedPosition.y;
break;
}

//Call method back
void *args[] = { &posX, &posY };
mono_runtime_invoke(trackPadTouchCanceledMethod, NULL, args, NULL);
}


- (void)mouseDown:(NSEvent *)event
{
float mPressure = 0.0f;
mPressure = [event pressure];

void *args[] ={ &mPressure };
mono_runtime_invoke(mouseDownMethod, NULL, args , NULL);

}

NSEvent touchesMatchingPhase:inView: - in XCode you can jump right to the docs by right clicking or using the "inspector pane" in the right side of the window.

So basically what this does is it gets the NSTouch objects (ie "the touches") from the event that match your criteria, that is NSTouchPhaseBegan, and in the view (presumably the window's contentView that was talked about earlier if I recall correctly). Anyway, this method is intended for creating custom gestures (like the zoom & swipe gestures) -- you'd interpret a series of touch events with this method and then take action if they fit what you want to do.

You want pressure data from a tablet, so anything in NSEvent involving touches is afaik not what you want to look at. Tablet events are basically mouse events, with some extra info (such as pressure). There are basically three phases to a touch/mouseclick, called in order:

-(void)mouseDown:(NSEvent *)event (once, when the click begins)
-(void)mouseDragged:(NSEvent *)event (multiple times, as the mouse/stylus/finger is dragged)
-(void)mouseUp:(NSEvent *)event (once, when the click stops)

If you want to keep sending messages while the stylus/finger is moving along the tablet, you should implement mouseDragged, it'll be called automatically as new info comes through.

So I think basically you should have a mouseDragged method where you keep sending the pressure to the mono_runtime_invoke call (this last part I don't know anything about).

quote:

EDIT:
So this is actually working but it only delivers the event when I click on the certain parts of the screen, I figure this is because I'm not calling InView:view, as I get an error that I need a ":". I'm not sure what to declare between the event and the InView.

Cocoa methods (actually called selectors) have multipart names, so you can't just add "inView:" to a method - check out the names in the NSEvent link above, those are the only valid methods you can call without adding categories/etc.

Events propagate down through the hierarchy of views/responders and if some object grabs it, it usually stops there. So it sounds that's what's happening, some other thing is covering your view (the object where you've implemented mouseDown:) and eats the events. Presumably there are some objects on the screen there where your code isn't registering.

Man this is a ramble, hopefully it makes sense.

HolyJewsus
Jun 26, 2006
Disgruntled By Flashing and Blinking Lights.
Thanks, it's making sense.

I'm getting mouseDown and mouseDragged events on certain sections of the screen, and trackpad events everywhere, I thought it would have to do with InView:view line. View is defined as the context view as you said.

HolyJewsus fucked around with this message at 00:22 on Feb 3, 2012

Adbot
ADBOT LOVES YOU

SheepThrowinBoy
Sep 20, 2003

"Joel, what are these films
supposed to teach us?"

"We're born, we die, & there is
a lot of padding in between."

Carthag & pokeyman & everyone posted:

Get your hands dirty

This is a good idea. I may be a few steps away from even knowing enough to just dive in, but I'm close. And I have a decently easy starter program in my head (basically a list maker/keeper with photo and web references). Kind of like what Bob Morales was suggesting.

I don't know a single line of C, except what I can kind of mimic from the Rory Lewis book. That first Hello World app felt awesome, but I was still a little confused about HOW I did it. Backing off from iOS specifically is definitely feeling like some good advice. Plus I'd get a kick out of making some cheesy text-based games as practice.

Here's a possibly dumb question: Assuming I am going to back off and build my knowledge of C or Python, can I still use Xcode for both of those languages? I'm guessing C: yes and Python: no. In fact now that I look more closely at the Python site I'm sure of it. I'm getting a TON of Xcode help from the first few chapters of Beginning iOS Game Development by Patrick Alessi on what, exactly, the program can does.

So... yeah. Thanks! I think I'm headed in the right direction. Is there any advantage/disadvantage to signing up for a cheap community college course or online program to learn these basics, or is that more of a "depends on how you learn" question? If you have any experience with online learning, any suggestions on which program I should consider? I have access to a lot of C books and ebooks via my brother, so if all else fails I'm just going to pour through a couple of those.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply