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 \$3,400 per month for bandwidth bills alone, and since we don't believe in shoving popup ads to our registered users, we try to make the money back through forum registrations.
«117 »

#### NOG posted:

In Flash, you can normalize a velocity by using this: vel.normalize(speed). But in Objective C or Cocos2d, what is built in? I know of ccpNormalize(vel), but I don't understand how I can make it work like the Flash one. I guess if I knew more about normalization I'd just do the math, but is there anything built in?

Normalizing a vector scales it so that it has a magnitude of 1. I presume that the speed parameter in that normalize method is to scale the vector after normalizing it. You can achieve the same effect in the second example by scaling the vector manually after normalizing it. Just multiply each component of the vector by the speed, as in:

##### code:
``````ccpNormalize(vel);
vel.x *= speed;
vel.y *= speed;
``````
That's certainly what the flash function does internally anyways.

That's what was stumping me, I thought I was doing that and it resulted in acting crazy.
I ended up doing this:

##### code:
``````//get a direction
CGPoint dir = ccpNormalize(heroVelocity);

//then use ccpMult to the direction with a speed
heroVelocity = ccpMult(dir, heroSpeed);
``````

#### Small White Dragon posted:

Hey Clang friends:

I'm hearing about Clang LLVM 3.0, but the current version is 2.9 and I don't see any info on 3.0. Given it's an open source project, can you talk about (or point to) some info about 3.0?

For the open source project, we're hoping to have C++ '0x, C++ static analysis, and a lot of other things that aren't quite as user-visible like a much-improved exceptions model.

I can't talk about future goals for the Apple product, but I will point out that companies contributing to open-source projects often develop crazy new features privately before pushing them to trunk. Like, say, LLVM's ARM backend, which was not contributed until after the iPhone was announced.

#### NOG posted:

That's what was stumping me, I thought I was doing that and it resulted in acting crazy.
I ended up doing this:

##### code:
``````//get a direction
CGPoint dir = ccpNormalize(heroVelocity);

//then use ccpMult to the direction with a speed
heroVelocity = ccpMult(dir, heroSpeed);
``````

Ahh, well it looks like ccpNormalize returns a new normalized point rather than normalizing the point you pass in. Given that that's the case, just saying ccpNormalize(vel) isn't going to do anything, so the previous code would just cause the velocity to grow really fast. That's probably what was causing the crazy behavior.

 lord funk Feb 16, 2004 So apparently the UIKeyboardWillShowNotification and UIKeyboardWillHideNotification notifications are called when the UIKeyboard is active and you rotate the iOS device. This is a bit weird, since the keyboard doesn't actually hide itself or show itself, but rotates just like a normal view. Now it's messing with my interface - I use the 'hide' notification to reset a UIScrollVIew content position, but it gets called every time I rotate now. Anyone run into this before? Edit: nevermind, just made a _isRotating bool to keep track of things. My orientation code is like a Rube Goldberg machine. lord funk fucked around with this message at Apr 20, 2011 around 13:49 # ? Apr 20, 2011 02:02
 klem_johansen Jul 10, 2002 [be my e-friend] Got a client who needs a relatively simple app to run on iOS, Android & Blackberry. So, naturally I'm looking into Phonegap since it's more or less a web-app that needs access to the camera. Has anyone heard of apps getting bounced by Apple for using Phonegap? # ? Apr 20, 2011 22:21
 KuruMonkey Jul 23, 2004 Can anyone recommend a getting started / introduction tutorial to XCode that refers to either of the currently available versions of XCode? (I don't care which) Its actually quite an initial hurdle when even the Hello, World examples in my books keep refering to elements of XCode that have been moved/renamed/removed - even the type of beginning application template they refer to is no longer available, and there's nothing that seems to match up. # ? Apr 21, 2011 07:07
 xzzy Mar 5, 2009 Tonight's starting lineup is brought to you by Satan. Xcode 4 is a complete redesign, none of the documentation has caught up. Same features are there, you just gotta hunt around for them. Dig up a download of Xcode 3.. the documentation will match a lot better. # ? Apr 21, 2011 14:22

#### KuruMonkey posted:

Can anyone recommend a getting started / introduction tutorial to XCode that refers to either of the currently available versions of XCode? (I don't care which)

Its actually quite an initial hurdle when even the Hello, World examples in my books keep refering to elements of XCode that have been moved/renamed/removed - even the type of beginning application template they refer to is no longer available, and there's nothing that seems to match up.

http://paulpeelen.com/2010/10/01/pr...world-tutorial/

My current serious confusion: I'm trying to figure out how to work with streaming video and do some extremely simple live processing. Apple provides this example "function"
http://developer.apple.com/library/...0010188-CH2-SW4
But isn't that not a function. I thought functions had names like ImAFunctionAndITakeArg1:Arg2: etc. When I paste that into a class I can't get it to compile even after adding what seems like appropriate headers. I'm sure the answer involves me being dumb, but I'd like to hear it.

modig fucked around with this message at Apr 21, 2011 around 14:42

#### modig posted:

http://paulpeelen.com/2010/10/01/pr...world-tutorial/

My current serious confusion: I'm trying to figure out how to work with streaming video and do some extremely simple live processing. Apple provides this example "function"
http://developer.apple.com/library/...0010188-CH2-SW4
But isn't that not a function. I thought functions had names like ImAFunctionAndITakeArg1:Arg2: etc. When I paste that into a class I can't get it to compile even after adding what seems like appropriate headers. I'm sure the answer involves me being dumb, but I'd like to hear it.

That's a c-style function, stick it in an implementation file but outside of a class. Put the prototype in a header file but outside a @interface block. The you can call it from your Objective-C code just like you call functions like NSLog. You may need to do conversion of parameters in some cases but classes like NSString and NSDatahave methods that will convert to standard C types (eg: char*) and back (and some classes are toll-free bridged to Foundation types so a pointer to NSString can be used as a CFString* without conversion.)

#### modig posted:

http://paulpeelen.com/2010/10/01/pr...world-tutorial/

My current serious confusion: I'm trying to figure out how to work with streaming video and do some extremely simple live processing. Apple provides this example "function"
http://developer.apple.com/library/...0010188-CH2-SW4
But isn't that not a function. I thought functions had names like ImAFunctionAndITakeArg1:Arg2: etc. When I paste that into a class I can't get it to compile even after adding what seems like appropriate headers. I'm sure the answer involves me being dumb, but I'd like to hear it.

To only answer part of your question: for some things / frameworks, they use straight C.

EDIT: curse you Ender.UNF

 modig Aug 20, 2002 Ohh ok, so I need to put it in a .mm file I guess. I'll mess with that later today, thanks. # ? Apr 21, 2011 15:02
 modig Aug 20, 2002 Is there any way to simulate video input in the iOS simulator? I'm trying to process video data using , and I think I finally got the Delegate setup somewhat. I tried just adding an NSLog call to the captureOutput:didOutputSampleBuffer:fromConnection: function, but it doesn't seem to be called ever. It's quite possible something else is still messed up, but I'd be more confident with the simulating if I could have some video input (I'd see it playback since I currently have a preview layer setup). # ? Apr 22, 2011 04:45

#### modig posted:

Ohh ok, so I need to put it in a .mm file I guess. I'll mess with that later today, thanks.

You use .mm when you need Objective-C++. If you're just mixing some straight C into your Objective-C, .m is fine.

#### quote:

I thought functions had names like ImAFunctionAndITakeArg1:Arg2: etc.

This construct is known in Objective-C as a selector. It's known as such because it allows the runtime to select the code to execute; the method that will be called when the program runs is not determined until runtime.

You send a message to a receiver ("invoke/call a method") like so:

##### code:
``[myObj setValue:@"foo" forKey:@"bar"];``
At compile time, this gets converted into a call to a function named objc_msgSend. The arguments to the call include the object itself, the selector name, and all of the arguments you provided. The function looks like this:

##### code:
``id objc_msgSend(id theReceiver, SEL theSelector, ...)``
In the example, the selector name is the fully qualified string "setValue:ForKey:", colons included. Selectors actually have a special type once compiled, known as SEL. When you need to refer to a selector for some reason, you use the @selector() compiler directive. I'll just quote the documentation for SEL here, since I would just be rephrasing it:

Method selectors are used to represent the name of a method at runtime. A method selector is a C string that has been registered (or “mapped“) with the Objective-C runtime.

Going back to the example, the code generated by the compiler is equivalent to (for our purposes here):

##### code:
``objc_msgSend(myObj, @selector(setValue:forKey:), @"foo", @"bar");``
At runtime, objc_msgSend resolves the selector to a method implementation, which is the actual executable code for the method being invoked.

Homework:

The Objective-C Programming Language
The Objective-C Runtime Programming Guide

Mikey-San fucked around with this message at Apr 22, 2011 around 08:02

#### Mikey-San posted:

Objective-C Runtime Programming Guide

Sniped for the OP. Thanks!

#### Mikey-San posted:

stuff +
Homework:

The Objective-C Programming Language
The Objective-C Runtime Programming Guide

Thanks, still wrapping my head around the basics.

#### modig posted:

Thanks, still wrapping my head around the basics.

I admit that I was a little worried my reply was overkill. The most relevant part is the "construct" bit explaining the higher-level idea of a selector.

Once I started going, I couldn't stop . . .

 KidDynamite Feb 11, 2005 No, Mr. Rice, I expect you to score. Just a quick question for you guys I should be able to completely code compile and run programs on a hackintosh? I want to start coding asap but don't have the funds for a MBP yet. # ? Apr 23, 2011 00:53

#### KidDynamite posted:

Just a quick question for you guys I should be able to completely code compile and run programs on a hackintosh? I want to start coding asap but don't have the funds for a MBP yet.

As far as I know, yes. But please don't yell at me if that's wrong.

#### Sir Davey posted:

I have nothing useful to tell you about anything in your post, but for what it's worth I'm perfectly happy with App Store chat here, so by all means.

#### Sir Davey posted:

2.13: Apps that are primarily marketing materials or advertisements will be rejected

And that's it. What should we do from here? Our client won't pay us until the app is in the store, I've already poured many hours into this app and it's pissing me off. Right now the app does not have much content because the client did not give us any. I had to make up for it by looking at other sites in which they are referenced to get some flyers/events, but we only have 1 photo gallery and 1 video and 1 music... I'm guessing that's a large part of the issue?

I think the issue is that it is an advertisement for the club. You could always ask specifically how the app is advertising, or how the reviewers saw that it was just an advertisement. To me it seems like one, but that's just my opinion.

I'm getting a linker error when I try to call [AVCaptureSession alloc], and I don't understand why. I have copied the exact call from an example program I downloaded, and it works when I run that program. I imported all stuff that was imported in the example program.

CaptureSessionController.h
##### code:
``````#import <CoreMedia/CoreMedia.h>
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>

@interface CaptureSessionController : NSObject <AVCaptureVideoDataOutputSampleBufferDelegate> {

}

@property (retain) AVCaptureSession *captureSession;
@property (retain) AVCaptureConnection *captureConnection;
@property dispatch_queue_t dQueue;

- (void) StartSession;
- (void) captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection;

@end
``````
CaptureSessionController.m
##### code:
``````#import "CaptureSessionController.h"

@implementation CaptureSessionController

@synthesize dQueue;
@synthesize captureSession, captureConnection;

+ (id)init {
if ((self = [super init])) {
[self setCaptureSession:[[AVCaptureSession alloc] init]];
}
return self;
}
some other methods that don't do anything yet (everything is commented out inside them)
``````
The error:
##### code:
``````Undefined symbols for architecture i386:
"_OBJC_CLASS_\$_AVCaptureSession", referenced from:
objc-class-ref in CaptureSessionController.o
collect2: ld returned 1 exit status
``````

 Doc Block Apr 15, 2003 Make sure you've got the right frameworks added to the project. # ? Apr 23, 2011 18:18

#### Doc Block posted:

Make sure you've got the right frameworks added to the project.

I had no idea what this meant, but googled around and figured it out. Thanks.

Useless rant:
I loving thought thats what the #import command was for... why didn't it just say "hey you cant loving import that, its not part of the project".

#### modig posted:

Useless rant:
I loving thought thats what the #import command was for... why didn't it just say "hey you cant loving import that, its not part of the project".

You're absolutely right that that's how it should work, but sadly that's just not how it actually does under the C separate compilation model. #import/#include directives have no idea what runtime libraries are associated with a header file, and even if they did, there's no way for the compiler to collect all that information and present it to the linker.

#### modig posted:

I had no idea what this meant, but googled around and figured it out. Thanks.

Useless rant:
I loving thought thats what the #import command was for... why didn't it just say "hey you cant loving import that, its not part of the project".

#import and #include are preprocessor directives. They tell the preprocessor to read in the contents of whatever file you've specified and put those contents in place of the #import/#include directive. It has nothing to do with adding things to the project, because a .h file isn't a framework or a library, and the actual compiler never even sees the preprocessor directives.

And the reason it didn't fail at the #import directive is because the preprocessor could read the file you specified. The file doesn't even have to be a .h file, it could be a C or Objective-C source file, or a big commented-out text file, or whatever.

#### Sir Davey posted:

Our client won't pay us until the app is in the store,

While this isn't the most helpful to you now, in the future your contract should stipulate that if the app is rejected due to policy (as opposed to bugs or using private APIs) you aren't responsible for the work necessary to fix the design and are still supposed to be paid. If your finished code fits their spec it isn't your problem if the spec isn't an allowed app.

That said, I think you are right that more non-advertising content is probably what's necessary here. But you should make sure that any future work you do on this is paid and try to get them to agree to pay you regardless of the acceptance status.

I did a contract app and when we had finished the app it came out that Apple didn't want to allow that entire class of app. Him not paying me there would have been a huge dick move.

#### rjmccall posted:

You're absolutely right that that's how it should work, but sadly that's just not how it actually does under the C separate compilation model. #import/#include directives have no idea what runtime libraries are associated with a header file, and even if they did, there's no way for the compiler to collect all that information and present it to the linker.

People need to remember that for backwards-compatibility and other reasons, the straight C languages are still laboring under the compiler restrictions imposed on 1970s mainframes. In the days of limited memory and CPU time, it was far more important to make the humans do the compiler's work for it as much as possible.

The current setup lets the compiler just read the header files (processing as they go which is why it will barf if it sees functions out of order without a prototype), pretending the headers are part of the source file, then read the source file. When it sees a type that exists in another file, the compiler doesn't actually know anything about that type except what the headers tell it because it literally doesnt have that other file in memory at the time. This scheme also let's you cache the OBJ files so if only one source file changes you can compile it then relink against the existing OBJ files. It is at the link stage that you actually resolve all those framework symbols (function names). Granted, I doubt LLVM is actualy doing it this way but in principal you can still write an Objective-C compiler that runs with 640k memory on a 386.

It should be possible to indicate in the header files what framework is required, but that would require adding actual metadata attributes to C and good luck with that. Not to mention you'd need to introduce the idea of versioning, which would be nice but has other complications associated with it.

C#/Java on the other hand are perfectly happy to cache all the referenced library metadata as well as continuously compile all the source files in the background and keeping the resulting AST/metadata in memory because memory is cheap and we all have multicore machines that have idle processors most of the time. So they will just remember that they saw an unknown type in the first pass, then hook up the reference to the definition even when they appear out of order. They can also deal with multiple versions of libraries, mismatched calling conventions, etc because of their VM runtime nature. That is really problematic when you have ObjC calling C functions and vice-versa in a way that doesn't horribly break everything.

edit: this is not for your benefit rjmcall, I don't have any intention of explaining black holes to hawking or atheism to Dawkins. Also, is there any publicly available information on Objective-C 3?

Ender.uNF fucked around with this message at Apr 24, 2011 around 02:20

#### Ender.uNF posted:

Also, is there any publicly available information on Objective-C 3?

Well, this guy really wants some kind of support for anonymous functions, and while I'm pretty sure we won't rip out blocks if/when we release something called ObjC3, you never know.

Otherwise I hope not.

 modig Aug 20, 2002 So I signed up for the iOS Developer Program, and I got an email that said I can finish enrollment, but I actually can't. I emailed Apple support on Friday and have yet to get any response. I was planning to test my App on my iPhone this weekend, but I guess that's not going to happen. edit: Can I access the readings from the ambient light sensors in the iPhone? I'm pretty sure I can't, so I'm trying to figure out how to use the video camera to measure the light level by basically taking the average value of the pixels in a video frame. So far I'm planning to use captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection to get frames as they come in, but I'm having a hard time figuring out how to access and average the pixel rgb values in a CMSampleBufferRef. modig fucked around with this message at Apr 24, 2011 around 05:34 # ? Apr 24, 2011 04:18
Is there a way to make things more ... complaney?

I'm creating an instance of a subclass of UIViewController I made inside my application:didFinishLaunchingWithOptions:, and initializing it with initWithNibName:, but as far as I can tell, it's just not loading the NIB. I made a UITabBarController in the XIB, and hooked it up to an outlet in my subclass, but I'm getting something like this:

##### code:
``````// MyViewControllerSubclass.h
@interface MyViewControllerSubclass : UIViewController { }

@property (nonatomic, readonly, retain) IBOutlet UITabBarController* tbc;

@end

// MyViewControllerSubclass.m
@implementation MyViewControllerSubclass

@synthesize tbc = _tbc;

@end

// AppDelegate.m (partial)
-(BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions(NSDictionary*)launchOptions {

MyViewControllerSubclass* vc = [[MyViewControllerSubclass alloc] initWithNibName:@"MyNibName"];

// This would evaluate to TRUE. Why isn't my outlet being hooked up?
// I suspect it's that "MyNibName" isn't actually being loaded, but I have
// no idea how to tell--if I replace "MyNibName" with "blargle", which
// doesn't exist in my project, no errors are raised.
vc.tbc == 0x0;

// This works just fine, even though it's nil. Argh! I get that properties
// are implemented as messages, and sending a message to nil is allowable, but
// is there a way to make this complain while I'm developing?
vc.tbc.view == 0x0

}
``````
Is there an error log somewhere that I can look at to at least see for sure whether my XIB/NIB is being loaded? Or something I can turn on so the app will
crash when it tries to load a XIB/NIB it can't find?

 modig Aug 20, 2002 ^^ Sorry no idea ^^ Does the TV out in the simulator just not work or something? Every time I activate it my App quits back to the main iPhone screen and the debugger says "Terminating in response to SpringBoard's termination. " It's not just my App, I downloaded the "Touches" sample code App and the same thing happens with that. I also commented out the internals of all the functions that have anything to do with adding a new screen, and the same thing happens. # ? Apr 25, 2011 02:30

#### modig posted:

^^ Sorry no idea ^^

Does the TV out in the simulator just not work or something? Every time I activate it my App quits back to the main iPhone screen and the debugger says "Terminating in response to SpringBoard's termination.
"

It's not just my App, I downloaded the "Touches" sample code App and the same thing happens with that. I also commented out the internals of all the functions that have anything to do with adding a new screen, and the same thing happens.

Have you tried having the TV out open in the simulator before starting your app?

#### wellwhoopdedooo posted:

Is there a way to make things more ... complaney?

Judging by your "==" tests it looks like you might want to use "assert()"?. Sorry if I've misunderstood.

#### wellwhoopdedooo posted:

I'm creating an instance of a subclass of UIViewController I made inside my application:didFinishLaunchingWithOptions:, and initializing it with initWithNibName:, but as far as I can tell, it's just not loading the NIB. I made a UITabBarController in the XIB, and hooked it up to an outlet in my subclass, but I'm getting something like this:

Nibs aren't loaded on init. You have to call "view" on the controller to trigger nib loading. Your outlets and actions should be hooked up after that. I think that might be your problem.

##### code:
``````// This works just fine, even though it's nil. Argh! I get that properties
// are implemented as messages, and sending a message to nil is allowable, but
// is there a way to make this complain while I'm developing?
vc.tbc.view == 0x0
``````
I'm sure there's probably a way you could cause this to fail, but it would probably wreak all kinds of havoc as I'll bet all the Apple frameworks lean on this (including synthesized accessors).

#### samiamwork posted:

Judging by your "==" tests it looks like you might want to use "assert()"?. Sorry if I've misunderstood.

Not really, I probably should have put in NSAssert() to make it more clear, this wasn't actual code, just an illustration of the question.

#### samiamwork posted:

Nibs aren't loaded on init. You have to call "view" on the controller to trigger nib loading. Your outlets and actions should be hooked up after that. I think that might be your problem.

Yep, this was exactly it, thanks!

#### samiamwork posted:

I'm sure there's probably a way you could cause this to fail, but it would probably wreak all kinds of havoc as I'll bet all the Apple frameworks lean on this (including synthesized accessors).

I guess I already ran into it when I had to turn off a bunch of the warnings because they were getting hit hundreds of times in the framework headers and couldn't figure out a way to get GCC or LLVM to treat them as system headers. Oh well, thanks again!

#### OHIO posted:

Have you tried having the TV out open in the simulator before starting your app?

I just tried this. I don't have my app setup to look for the TV out when it starts up yet, so it doesn't test much. But it loads up OK, then if you disable the TV out it crashes with that same springboard error. Same behavior in the touches App which doesn't do anything with the TV out.

Here are some basic questions:

##### code:
``````@synthesize window=_window;
``````
What does the _window mean? How is it different from not having an underscore?

As far as memory management goes, the guidelines seem to be that I should release any object I own. What does it mean for me to own it? I'm guessing that if I call the alloc function directly, I probably own it. Also I guess any @property with retain counts. What else counts as me owning it?

 lord funk Feb 16, 2004 A bit of coding livejournal bloggering ahead: I just realized that my Model - View code could have been designed with much less code if I had used NSSets instead of NSArrays, and passed references of the Models to the Views. As it is now, I'm keeping track of array indexes and passing those back and forth instead to keep everybody attached to their corresponding Model / View. What kills me is that my solution works perfectly well, and I would gain nothing by redoing it. I haaaate knowing that I chose the roudabout way of coding it, but it would be a waste of time to redo all of it. Nnnrrrhghghg.... # ? Apr 25, 2011 15:45

#### modig posted:

##### code:
``````@synthesize window=_window;
``````

In English, that says "Create the setter & getter for the property 'window', using the variable '_window'". Using the underscore in the private variable name is just a coding style thing.