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
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!

I'm trying to do little iPhone app where you enter a set of 3 (x,y) coordinates, and then you touch the 'draw' button and it creates a new view and draws it on the screen. Easy enough, right?

I created a Single-view Applications using Xcode. So it gave me an AppDelegate, ViewController, and Xib file. I put the text fields and buttons and then when you click the button, it loads another Xib file and controller:
code:
    canvasViewController = [[CanvasViewController alloc] initWithNibName:@"CanvasViewController" bundle:nil];
    [self.view addSubview:canvasViewController.view];
That Xib file has the view set to a custom class that I made, CanvasView. Right now it just draws a blue diagonal line so that I know it's getting that far.

Here's where I'm stuck since I'm still stuck thinking of this in other languages. How do I get the numbers from the first screen (using [UITextField.text intValue]) to the second one?

I tried making properties in the CanvasViewController class but that's where I got stuck. I need to get those variables to the view. I thought I could just do something like [view filesowner].x1 or something.

I could probably do this a 'triangle' singleton, right?

Adbot
ADBOT LOVES YOU

Doc Block
Apr 15, 2003
Fun Shoe
Something like this:
code:

// TriangleViewController.h

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@interface TriangleViewController : UIViewController

// A bunch of CGPoints wrapped in NSValues, stuffed in an array.
// Advantage of this instead of one property per point is that it'll be easier to add more
// points later if you want to.

@property (nonatomic, retain) NSArray *vertexArray;    // replace retain with strong if you're using ARC

@end

// TriangleViewController.m

#import "TriangleViewController.h"

@implementation TriangleViewController
@synthesize vertexArray=_vertexArray;

// blah blah blah

- (void)drawInRectOrWhateverIForget:(CGRect)rect
{
	// blah blah blah set up your context

	if(_vertexArray != nil) {
		// draw your stuff
	}
}

// blah blah blah

@end
and when you want to pass the points you'd do
code:

- (IBAction)drawTriangleWasTapped:(id)sender
{
	TriangleViewController *triangleViewController = [[TriangleViewController alloc] init];
	
	NSArray *array = [[NSArray alloc] initWithObjects:[NSValue valueWithCGPoint:_point0],
							  [NSValue valueWithCGPoint:_point1],
							  [NSValue valueWithCGPoint:_point2],
							  nil];
	triangleViewController.vertexArray = array;

	// blah blah blah
}

Doc Block fucked around with this message at 05:09 on Apr 18, 2012

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

xgalaxy posted:

Client is using Unity3d, which is compiled arm only.
Client claims we are using thumb in our native library and that they are getting a crash because of it.

They use the otool as proof, and seem unwilling to accept anything but arm only.

To be fair, the assembly looks like thumb code, but it seems to be filled with b.n ops every other line...

The thing is, instruction formats — especially 16-bit instruction formats — are so densely encoded that pretty much any arbitrary byte sequence can be interpreted as an instruction stream. My understanding is that otool tries to distinguish them by recognizing likely ARM prologues vs. likely THUMB ones, but that's obviously a fallible heuristic.

In this case, this is pretty clearly an ARM instruction sequence, because if you reinterpret it as 32-bit (little-endian) instructions, the top four bits of almost every instruction are 1110. In the ARM instruction format, the top four bits are the condition code, and 1110 means "always". I also took the time to manually decode the first instruction, and (if I got it right) it's ldr r3, [r0, #8], which is pretty plausible.

Kyth
Jun 7, 2011

Professional windmill tilter
I have an app that has a main menu (scene 1). Select the first option, it takes you to a screen that allows you to set some options (2) and then transitions to a final scene (3) where you do various things. When you're done, you go back to the main menu.

A navigation controller, pushing views on the stack, seems wrong with a 1->2->3->1 series of transitions. (feel free to tell me if I'm wrong; new to iOS)

So I tried to do it with a Custom Segue. This, of course, works from Apple's documentation at https://developer.apple.com/library/IOs/#featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomSegues/CreatingCustomSegues.html :

code:
- (void)perform {
  // add your own animation code here
  [[self sourceViewController] presentModalViewController:[self destinationViewController] animated:NO];
}
Changing it from presentModalViewController:animated: to presentViewController:animated:completion: worked as well.

Flush with success, I tried to add animation by following some online examples, but I seem to be missing some fundamental point because I don't actually get any animation (although the views do transition).

Example of non-animating code:

code:
-(void)perform {
  UIViewController *src = (UIViewController *) self.sourceViewController;
  UIViewController *dst = (UIViewController *) self.destinationViewController;

  [UIView transitionWithView:src.navigationController.view duration:0.2
                     options:UIViewAnimationOptionTransitionCrossDissolve
                  animations:^{
                    [src presentViewController:dst animated:NO completion:NULL];
                  }
                  completion:NULL];
}
Putting it in a UINaviationController and using the original code I got that from (identical to the above except a different transition and pushViewController:animated:) shows animation, but using it without the push doesn't.

xgalaxy
Jan 27, 2004
i write code

rjmccall posted:

The thing is, instruction formats — especially 16-bit instruction formats — are so densely encoded that pretty much any arbitrary byte sequence can be interpreted as an instruction stream. My understanding is that otool tries to distinguish them by recognizing likely ARM prologues vs. likely THUMB ones, but that's obviously a fallible heuristic.

In this case, this is pretty clearly an ARM instruction sequence, because if you reinterpret it as 32-bit (little-endian) instructions, the top four bits of almost every instruction are 1110. In the ARM instruction format, the top four bits are the condition code, and 1110 means "always". I also took the time to manually decode the first instruction, and (if I got it right) it's ldr r3, [r0, #8], which is pretty plausible.

I think you are right.
What seems most telling is that otool output of the object file itself looks fine.

Thanks for taking the time to help me sort this out.

Doc Block
Apr 15, 2003
Fun Shoe

Kyth posted:

I have an app that has a main menu (scene 1). Select the first option, it takes you to a screen that allows you to set some options (2) and then transitions to a final scene (3) where you do various things. When you're done, you go back to the main menu.

A navigation controller, pushing views on the stack, seems wrong with a 1->2->3->1 series of transitions. (feel free to tell me if I'm wrong; new to iOS)


This is perfectly fine, so long as you pop off the scenes at the end instead of just pushing another Scene 1.

Make Scene 1 the navigation controller's root view controller, and then at the end of Scene 3 you'd just do something along the lines of
code:
[self.navigationController popToRootViewController animated:YES]
to go back to Scene 1.

Doc Block fucked around with this message at 07:27 on Apr 18, 2012

Small White Dragon
Nov 23, 2007

No relation.
What tools (if any) are people using for Project Management?

bumnuts
Dec 10, 2004
mmm...crunchy
You should strongly consider project.pbxproj

LP0 ON FIRE
Jan 25, 2006

beep boop

Doc Block posted:

Not to be a jerk, but if the parent property wasn't set somewhere then yeah, it isn't going to work.

Also, is JoinedMapsLayer a descendent of CCNode? (if it's a descendent of CCLayer then it is). If so, you shouldn't need to make your own mutable array of sprites; each CCNode has its own array of all its children. Just do [joinedMapsLayer addChild:someSprite] or something and it will add it to joinedMapsLayer's CCArray and set someSprite's parent to joinedMapsLayer. And when joinedMapsLayer is drawn all its children will be drawn, etc.

Inside your joinedMapsLayer code you can access the child objects by accessing the children property.

Check out the documentation for CCNode (1.1 here, 2.0 here) and for CCArray (1.1 here 2.0 here).


Thanks for the info. Most of the sprites I add into arrays have a whole class included so I can edit my own custom properties. So after I make a temporary pointer off the array index I can just do tempClass.health -= 5 or access the sprite directly like tempClass.sprite.opacity = 25.

PT6A
Jan 5, 2006

Public school teachers are callous dictators who won't lift a finger to stop children from peeing in my plane

Bob Morales posted:

I'm trying to do little iPhone app where you enter a set of 3 (x,y) coordinates, and then you touch the 'draw' button and it creates a new view and draws it on the screen. Easy enough, right?

I created a Single-view Applications using Xcode. So it gave me an AppDelegate, ViewController, and Xib file. I put the text fields and buttons and then when you click the button, it loads another Xib file and controller:
code:
    canvasViewController = [[CanvasViewController alloc] initWithNibName:@"CanvasViewController" bundle:nil];
    [self.view addSubview:canvasViewController.view];
That Xib file has the view set to a custom class that I made, CanvasView. Right now it just draws a blue diagonal line so that I know it's getting that far.

Here's where I'm stuck since I'm still stuck thinking of this in other languages. How do I get the numbers from the first screen (using [UITextField.text intValue]) to the second one?

I tried making properties in the CanvasViewController class but that's where I got stuck. I need to get those variables to the view. I thought I could just do something like [view filesowner].x1 or something.

I could probably do this a 'triangle' singleton, right?

I might be completely wrong about it, but this is how I've handled things in the past. Create properties in CanvasView that essentially define what it needs to draw, and no more. Set these from the ViewController either when the ViewController is loaded, or when a ViewController property is updated. The custom drawing code should go in CanvasView's -(void) drawInRect method.

Doc Block: That would be a nice way to do it, but unfortunately drawInRect: is a method of UIView, not UIViewController, which makes things a bit more tricky.

AlwaysWetID34
Mar 8, 2003
*shrug*
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

AlwaysWetID34 fucked around with this message at 17:01 on Jan 18, 2019

Kyth
Jun 7, 2011

Professional windmill tilter

Doc Block posted:

This is perfectly fine, so long as you pop off the scenes at the end instead of just pushing another Scene 1.

Make Scene 1 the navigation controller's root view controller, and then at the end of Scene 3 you'd just do something along the lines of
code:
[self.navigationController popToRootViewController animated:YES]
to go back to Scene 1.

Hmm. Okay. The semantics of a navigation controller, with the title bar and the back buttons don't quite work in all the screens, but I'll go read the docs and see what I can do to deal with that.

Thanks for the help.

Still curious why the animation wasn't working in the custom segue outside of a push call, but that can wait until I need one. Maybe by then I'll know enough to puzzle through it on my own.

Doc Block
Apr 15, 2003
Fun Shoe

PT6A posted:

Doc Block: That would be a nice way to do it, but unfortunately drawInRect: is a method of UIView, not UIViewController, which makes things a bit more tricky.

Whoops! Yeah, drawInRect: is gonna be in your custom view's drawing code.

xgalaxy
Jan 27, 2004
i write code

rjmccall posted:

I also took the time to manually decode the first instruction, and (if I got it right) it's ldr r3, [r0, #8], which is pretty plausible.

BTW, I think you were close =D

quote:

build/ios/armv7/release/obj/libtommath/bn_mp_cmp_d.o:
(__TEXT,__text) section
_mp_cmp_d:
00000000 e1a02000 mov r2, r0
00000004 e3e00000 mvn r0, #0 @ 0x0
00000008 e5923008 ldr r3, [r2, #8]
0000000c e3530001 cmp r3, #1 @ 0x1
00000010 0a00000b beq 0x44
00000014 e5923000 ldr r3, [r2]
00000018 e3a00001 mov r0, #1 @ 0x1
0000001c e3530001 cmp r3, #1 @ 0x1
00000020 ca000007 bgt 0x44
00000024 e592000c ldr r0, [r2, #12]
00000028 e5902000 ldr r2, [r0]
0000002c e3a00001 mov r0, #1 @ 0x1
00000030 e1520001 cmp r2, r1
00000034 812fff1e bxhi lr
00000038 e1520001 cmp r2, r1
0000003c e3a00000 mov r0, #0 @ 0x0
00000040 33e00000 mvncc r0, #0 @ 0x0
00000044 e12fff1e bx lr

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
I think that's a different instruction stream. :) The first instruction in the one you posted before was definitely e5903008. It's equivalent, anyway, because the value in r2 in the new stream was copied there from r0 in the first instruction, so it's apparently just a slightly different register allocation. That's not surprising, because we've rewritten the register allocator since we last updated llvm-gcc.

xgalaxy
Jan 27, 2004
i write code

rjmccall posted:

I think that's a different instruction stream. :) The first instruction in the one you posted before was definitely e5903008. It's equivalent, anyway, because the value in r2 in the new stream was copied there from r0 in the first instruction, so it's apparently just a slightly different register allocation. That's not surprising, because we've rewritten the register allocator since we last updated llvm-gcc.

Yea it was recompiled with a different compiler.
Sorry :D

Anyway.
Thanks again for all your help.

some kinda jackal
Feb 25, 2003

 
 
I'm working through the Big Nerd Ranch 4th edition Cocoa for OSX book and I'm kind of banging my head against a wall with this one stupid visual thing:



How the flying gently caress do I get rid of this column resize separator? In the inspector, Table View columns are set to 1. I've tried flipping everything I can think of. I've connected my dataSource and the table works fine, it's just that stupid resize indicator that I can't get rid of.

Words can't describe the shame I feel having to ask a question this basic :qq:

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Turn off 'resizable', then hide and re-show the header.

some kinda jackal
Feb 25, 2003

 
 
Here's my inspector:



Do you mean uncheck "resizing" and then uncheck and re-check "headers"? Because I just tried that and no dice :(

dizzywhip
Dec 23, 2005

You might need to manually size the column in interface builder so that it takes up the width of the entire table.

some kinda jackal
Feb 25, 2003

 
 
Ugh, that's what I was worried about. What a kludge.

I'm actually going to ask on Big Nerd Ranch's website.

some kinda jackal fucked around with this message at 00:06 on Apr 19, 2012

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Yeah you did what I did. All I can say is worked on my machine :-(

some kinda jackal
Feb 25, 2003

 
 
drat. Wonder what the difference could be :(

If it's not too much trouble, could one of you guys try to open my project and see if you can get it to work right?

http://dl.dropbox.com/u/58959/SpeakLine.zip

e: I don't mean do any work for me, just try to disable the resize handle, build and run. Curious to see if it's my machine or my project or what.

some kinda jackal fucked around with this message at 00:36 on Apr 19, 2012

Carthag Tuek
Oct 15, 2005

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



What are yalls thoughts on readonly properties vs. method declarations?

code:
@interface MyClass : NSObject

- (NSArray)items;

//vs.

@property (readonly) NSArray *items;

@end

//the implementation is a method in both cases
I guess It's pretty much a style issue, what you want to communicate to whoever is reading the .h file. Any gotchas one should be aware of in either case?

E: Fixed typo

Carthag Tuek fucked around with this message at 00:41 on Apr 19, 2012

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Well first off you can't allocate objects on the stack, so it'd be NSArray *items.

The differences I can think of right now are: that you can declare a property as (non)atomic, whereas you'd have to put it in a comment over a method; and that properties can be enumerated separately from methods by the runtime.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Martytoof posted:

drat. Wonder what the difference could be :(

If it's not too much trouble, could one of you guys try to open my project and see if you can get it to work right?

http://dl.dropbox.com/u/58959/SpeakLine.zip

It gets fixed for me if I resize the table view in the xib so it's narrower than the column separator, then resize it back out to its old width.

Carthag Tuek
Oct 15, 2005

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



Er yeah that was a typo. NSArray *items indeed.

some kinda jackal
Feb 25, 2003

 
 
Ugh loving THANK YOU pokeyman. That's got to be a bug of some kind. Wonder if I should try to report it.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
If it helps, NSTableView is a total poo poo to work with.

xgalaxy
Jan 27, 2004
i write code

pokeyman posted:

If it helps, NSTableView is a total poo poo to work with.

This pretty much sums up any TableView like class in any language / framework I've ever used.

some kinda jackal
Feb 25, 2003

 
 
Hey is there a checkbox I can set somewhere to tell XCode to @synthesize my properties with the underscored local variables by default? I could have sworn it did that sometimes and I just created a new class and I had to go back and edit my @synthesize statements to reflect what I wanted.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
I haven't found such a wonderful checkbox. If it's any consolation, Xcode will autocomplete the underscore.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

xgalaxy posted:

This pretty much sums up any TableView like class in any language / framework I've ever used.

Yeah, it's an odd constant. UITableView might be the best I've seen and I still swear at it regularly.

some kinda jackal
Feb 25, 2003

 
 

pokeyman posted:

I haven't found such a wonderful checkbox. If it's any consolation, Xcode will autocomplete the underscore.

Yup. It seems to know what I want it to do so I was hoping there was some way to make it do it without my intervention. Ah well.

Well while I'm asking dumb XCode newb questions, I did something to where my debugger pane stays open after I stop my application. I can close it just fine, but it sticks around after I quit my app EVERY time so having to click to close it to get that screen real estate back is annoying.

Oh nevermind that's a behaviour thing I can change, because I NSLog some poo poo. I think I got this.

some kinda jackal fucked around with this message at 04:23 on Apr 19, 2012

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
It's in the new compiler in Xcode 4.4... Properties are always synthesized by default so no more @synthesize.

some kinda jackal
Feb 25, 2003

 
 
What really? So I can tell it to auto-synth the properties with underscores? :aaaaa:

That owns. 4.4'll probably be out by the time I'm doing any serious development anyway.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
rjmccall can confirm but I believe it just automatically makes the ivar with an underscore. You just don't have to think about it anymore.

duck monster
Dec 15, 2004

Small White Dragon posted:

What tools (if any) are people using for Project Management?

Redmine with some custom hooks to hudson for bigger projects where I'm running CI to make blinkenlights for nervous clients

Toady
Jan 12, 2009

Martytoof posted:

drat. Wonder what the difference could be :(

If it's not too much trouble, could one of you guys try to open my project and see if you can get it to work right?

http://dl.dropbox.com/u/58959/SpeakLine.zip

e: I don't mean do any work for me, just try to disable the resize handle, build and run. Curious to see if it's my machine or my project or what.

The workaround posted didn't work for me, but I entered a table column width of 204 in the size inspector, which hid the right edge.

Adbot
ADBOT LOVES YOU

Toady
Jan 12, 2009

Martytoof posted:

What really? So I can tell it to auto-synth the properties with underscores? :aaaaa:

Underscore-prefixed ivars will be the default for implicitly synthesized properties. You can override the behavior with an explicit @synthesize statement. But then you wouldn't get to experience one of the great programming joys, deleting unneeded code.

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