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
lord funk
Feb 16, 2004

I still use -(IBAction)name:(id)sender; for some of my methods instead of -(void) even though I don't use IB. I like the clarity of seeing which methods are called directly with interface actions.

Adbot
ADBOT LOVES YOU

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

wellwhoopdedooo posted:

Ah, the serialization (mostly) answers the question. I assume that there's some code that gets run in order to set the IBOutlet-type stuff in the ViewController classes (unless the ViewController instance is serialized too?) but, don't answer that parenthetical unless you know off the top of your head, I plan to research the details as soon as I get the chance.

Thanks everyone!

Outlet and action binding is handled by the nib loading code, not by the view controller. (Remember that this stuff is from the NeXTstep days.) The docs I linked earlier talk about how outlets get hooked up, so hit those up when you get a minute.

duck monster
Dec 15, 2004

Carthag posted:

Nibs basically works through the NSCoding protocol.

You interact with the properties of the objects when designing your interface in IB, such as setting the frame of a button, the values of things, bindings, all that. When you save it to a nib, the properties & ivars are serialized via encodeWithCoder:.

When your app loads a nib and recreates the interface, it does so via initWithCoder:

I think the actual coder used is probably a different one than the NSKeyedArchiver you'll normally see when working with NSCoding.

They go into it a little bit in the 2010 WWDC talk about custom Cocoa views. That's how you create your own IB view plugins too, like a custom button for instance.

I'd actually really like Apple to push the IB custom plugin deal a bit more. One of the things that gave Delphi its power was the ability to write custom "Controls" that neatly encapsulated functionality behind a fairly clean interface that could be dragged-dropped and then wired in. This made life a LOT easier when doing big projects on delphi cos sites like Torys delphi site had thousands of these things, most with permissive open source licenses so it was easy to just drop a control in that, say, provided graphing or whatever, hook it up, and have a prototype in time for the lunch meeting with the client. Nothing I've seen, except maybe VB (which was a terrible terrible language) , was as productive as that. Having a big library of custom IB "controls" for iphone + mac work would be a huge productivity bonus for me. I mean theres plenty of *libraries* out there, but there always seems to be so much lovely boiler plate involved with using them.

Carthag Tuek
Oct 15, 2005

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



pokeyman posted:

Why not make the sublayers the size of the actual rects they're drawing, position them appropriately, and then -hitTest: works?

Yeah I just did that and cleaned up a bunch of model/view contaminations in the process. Lots neater.

duck monster posted:

I'd actually really like Apple to push the IB custom plugin deal a bit more. One of the things that gave Delphi its power was the ability to write custom "Controls" that neatly encapsulated functionality behind a fairly clean interface that could be dragged-dropped and then wired in. This made life a LOT easier when doing big projects on delphi cos sites like Torys delphi site had thousands of these things, most with permissive open source licenses so it was easy to just drop a control in that, say, provided graphing or whatever, hook it up, and have a prototype in time for the lunch meeting with the client. Nothing I've seen, except maybe VB (which was a terrible terrible language) , was as productive as that. Having a big library of custom IB "controls" for iphone + mac work would be a huge productivity bonus for me. I mean theres plenty of *libraries* out there, but there always seems to be so much lovely boiler plate involved with using them.

Well I'm guessing their reasoning is that they prefer the usage of delegates and decoupling over subclassing, and they aren't fond of the idea of a thousand non-Mac-like controls floating around. They probably see it as a convenience for say a company that wants to be able to make it easier to split interface designers and coders into different teams, or something like that. Also I guess they aren't a thing in Xcode 4 anymore, I never really used them so sorry for bringing up deprecated tech if that's the case.

Carthag Tuek fucked around with this message at 23:36 on Jan 23, 2012

duck monster
Dec 15, 2004

yeah thats true. The downside of the zillions of controls thing with delphi was it was a bit too easy to create wild and completely insane UIs for things (I literally created a bright pink barbie themed UI once for a clients app (motored industrial camera controller) I was trying to coax into severing our contract because I hated the oval office) and apple dont want that, plus yeah the delegate thing.

duck monster fucked around with this message at 01:51 on Jan 24, 2012

Khelmar
Oct 12, 2003

Things fix me.
OK, another probably really stupid ObjC question.

I've got code that reads a CSV file in, and splits it into an array of arrays. Now, I need to go through the first line and figure out which columns contain which data.

My plan was to set up an array with the possible values, and compare the value of each column to that. Finally, I'd have an NSMutableDictionary with the keys as the column names and the values be the columns containing that kind of data.

The problem comes in trying to determine if the column value read in is part of the array. Here's my code:

code:
NSArray *headers = [[NSArray alloc] initWithObjects:@"Date",@"Aircraft Type", @"Aircraft Ident", @"Route of Flight", @"Time in Flight", @"Day Landings", @"Night Landings", @"Instrument", @"Simulated Instrument", @"Approaches", @"Simulator", @"Night", @"Cross Country", @"Solo", @"Pilot in Command", @"Second in Command", @"Dual", @"As Instructor", @"Remarks", nil];
            
NSArray *fileHeaders = [CSV objectAtIndex:0];
            
for (id arrayTest in headers)
{
       NSLog(@"Array: %@", arrayTest);
}
            
for (id obj in fileHeaders) 
{
       NSLog(@"Header: %@", obj);
       NSLog(@"In Array? %@", [headers containsObject:obj]);
}
The last NSLog throws an EXC_BAD_ACCESS. I know both headers and obj are declared, since if I don't have the last line, it prints both all the elements of the array (headers) and all the columns in the first line of the file (obj).

Zhentar
Sep 28, 2003

Brilliant Master Genius
The "%@" format specifier means 'call [obj description]'. You're using it on a BOOL.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
What Zhentar said. You want

code:
NSLog(@"In Array? %d", [headers containsObject:obj]);

Khelmar
Oct 12, 2003

Things fix me.
Thanks. I don't know why it's the simple stuff that keeps tripping me up.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
The compiler should really be warning about that, sorry.

Carthag Tuek
Oct 15, 2005

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



This is a little weird:

In an IKImageView subclass that I want to display an NSPopover in, and if I call it at the "wrong" time, I get an exception:

Catchpoint 2 (exception thrown).2012-01-24 12:10:57.284 Test[71927:1403] -[NSPopover showRelativeToRect:ofView:preferredEdge:]: view has no window. You must supply a view in a window.

I've overriden the view as follows to get some info as to why its window seems to be randomly nil:

code:
- (void) viewWillMoveToWindow:(NSWindow *)window
{
    NSLog(@"viewWillMoveToWindow %@", window);
    [super viewWillMoveToWindow:window];
}

- (void) viewDidMoveToWindow
{
    NSLog(@"viewDidMoveToWindow %@", [self window]);
    [super viewDidMoveToWindow];
}

- (void)removeFromSuperview
{
    NSLog(@"removeFromSuperview %@", [self window]);
    [super removeFromSuperview];
}
The results:
2012-01-24 12:09:59.024 Test[71927:1403] viewWillMoveToWindow <NSWindow: 0x101d9b5b0>
2012-01-24 12:09:59.025 Test[71927:1403] viewDidMoveToWindow <NSWindow: 0x101d9b5b0>
2012-01-24 12:09:59.026 Test[71927:1403] removeFromSuperview <NSWindow: 0x101d9b5b0>
2012-01-24 12:09:59.026 Test[71927:1403] viewWillMoveToWindow (null)
2012-01-24 12:09:59.026 Test[71927:1403] viewDidMoveToWindow (null)
2012-01-24 12:09:59.028 Test[71927:1403] viewWillMoveToWindow <NSWindow: 0x101d9b5b0>
2012-01-24 12:09:59.028 Test[71927:1403] viewDidMoveToWindow <NSWindow: 0x101d9b5b0>
2012-01-24 12:09:59.028 Test[71927:1403] viewWillMoveToWindow (null)
2012-01-24 12:09:59.028 Test[71927:1403] viewDidMoveToWindow (null)

The view remains visible and bindings etc are still active. It's just that it apparently no longer sits in the window (even though it looks like it). Is this some optimization trick? It may or may not do it a few times when first showing the window & view, sometimes with the view ending up with window = nil, sometimes not. I can't see a parttern to it.

Edit: I can fix it by using its superview but that seems counterintuitive:

code:
NSLog(@"[imageView window]: %@", [imageView window]);
NSLog(@"[imageView superview]: %@", [imageView superview]);
NSLog(@"[[imageView superview] window]: %@", [[imageView superview] window]);

2012-01-24 12:31:33.915 Test[72467:1403] [imageView window]: (null)
2012-01-24 12:31:33.916 Test[72467:1403] [imageView superview]: <IKImageClipView: 0x10420d720>
2012-01-24 12:31:33.916 Test[72467:1403] [[imageView superview] window]: <NSWindow: 0x101884e00>
Wouldn't a view's children be part of the same window as the view itself?

Carthag Tuek fucked around with this message at 12:35 on Jan 24, 2012

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
So I've ported my first iPhone app over to being a Universal app to support iPad. It was a bit of a pain in the rear end as the documentation for doing so never seems to have been hammered down but I got it working and now I'm the proud parent of a really big app.

However I ran into a bit of a snag involving orientation changing. The iPhone version only supports portrait but the iPad was so support either orientation. I know you can try to have the elements on the page auto-align, resize, and orient themselves through the visual editor but due to radically different portrait and landscape designs I decided to go the "two mains views in a single xib" route and have the app switch between the two when the device rotates. I'm doing that by

code:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // only rotate iPad
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        return YES;
    } else {
        return UIInterfaceOrientationIsPortrait(interfaceOrientation);
    }
}

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
    if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight)
    {
        self.view = self.landscapeView;
    }
    else
    {
        self.view = self.portraitView;
    }
Where landscapeView and portratView are linked to the view views in my xib. This works great once you're already on the page but for the life of me I can't get anything like it to fire when the page actually loads.

So my question is, on load, how do I set what the default view is? I thorugh the code from didRotateFromInterfaceOrientation into initWithNibName and viewDidLoad and nothing happened. Do I have to instantiate the default view somehow differently completely? I thought I read something about not using initWithNibName and using loadView instead but I'm not entirely sure how to hook all that up.

This is the last thing I've got to take care of before I can wrap this up. Any ideas you awesome goons?

Zhentar
Sep 28, 2003

Brilliant Master Genius
Is there a way to find the type of an object's property using KVO? Basically, I've got a key and a string, and I need to know whether or not I need to parse that string into an NSNumber before calling -setValue: forKey:.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice
Core Data Question:

I'm syncing data with a server: I want to create new managed objects if they don't exist, and update ones if the modified date for the entity on the server is newer than the one on the device. I've read through this: http://developer.apple.com/library/.../TP40003174-SW1

Since I dont' have any relationship data here, it seems that their suggestion to "..create managed objects for the entire set and weed out (delete) any duplicates before save using a single large IN predicate" would be appropriate for adding new people. Question is, how do I do that? how do I then get the duplicates and update based on that timestamp?

Core Data baffles me.

Carthag Tuek
Oct 15, 2005

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



Zhentar posted:

Is there a way to find the type of an object's property using KVO? Basically, I've got a key and a string, and I need to know whether or not I need to parse that string into an NSNumber before calling -setValue: forKey:.

As in you want to know what types it accepts? Usually that would be in the documentation, but I suppose you could do something like [[object valueForKey:@"key"] class] if you know it's an object and not a primitive or a struct.

Doc Block
Apr 15, 2003
Fun Shoe

Yodzilla posted:

So I've ported my first iPhone app over to being a Universal app to support iPad. It was a bit of a pain in the rear end as the documentation for doing so never seems to have been hammered down but I got it working and now I'm the proud parent of a really big app.

However I ran into a bit of a snag involving orientation changing. The iPhone version only supports portrait but the iPad was so support either orientation. I know you can try to have the elements on the page auto-align, resize, and orient themselves through the visual editor but due to radically different portrait and landscape designs I decided to go the "two mains views in a single xib" route and have the app switch between the two when the device rotates. I'm doing that by

code:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // only rotate iPad
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        return YES;
    } else {
        return UIInterfaceOrientationIsPortrait(interfaceOrientation);
    }
}

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
    if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight)
    {
        self.view = self.landscapeView;
    }
    else
    {
        self.view = self.portraitView;
    }
Where landscapeView and portratView are linked to the view views in my xib. This works great once you're already on the page but for the life of me I can't get anything like it to fire when the page actually loads.

So my question is, on load, how do I set what the default view is? I thorugh the code from didRotateFromInterfaceOrientation into initWithNibName and viewDidLoad and nothing happened. Do I have to instantiate the default view somehow differently completely? I thought I read something about not using initWithNibName and using loadView instead but I'm not entirely sure how to hook all that up.

This is the last thing I've got to take care of before I can wrap this up. Any ideas you awesome goons?

loadView is for setting up your view hierarchy programmatically. Your viewController's view property and all your outlets will already be wired up by the time you get to viewDidLoad.

So you could try copying the code from didRotateFromInterfaceOrientation to loadView and see if that works (don't forget to call [super loadView]).

Zhentar
Sep 28, 2003

Brilliant Master Genius

Carthag posted:

As in you want to know what types it accepts? Usually that would be in the documentation, but I suppose you could do something like [[object valueForKey:@"key"] class] if you know it's an object and not a primitive or a struct.

Yes, I want to know what type it accepts. And whether or not it's an object or a primitive is what I want to know most, so that method doesn't help me (it also doesn't help if the key you are setting is nil...).

Although, looking at the documentation again, this isn't as big an issue for me as I thought - I thought that setting value types required you to pass an NSValue object, but that's not quite the case; rather, it calls the appropriate -<type>Value method on the object you pass, and NSString implements the -<type>Value methods that I'd need so I won't have to do any conversion in those cases.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch

Doc Block posted:

loadView is for setting up your view hierarchy programmatically. Your viewController's view property and all your outlets will already be wired up by the time you get to viewDidLoad.

So you could try copying the code from didRotateFromInterfaceOrientation to loadView and see if that works (don't forget to call [super loadView]).

Yeah looks like no dice. Here's what I have:

code:
 - (void)loadView {
     [super loadView];
     UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
     if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight)
     {
         self.view = self.landscapeView;
     }
     else
     {
         self.view = self.portraitView;
     }
 }
And just in case it helps, here's how the actual page is being called when a button is clicked on the welcome screen in the RootViewController:

code:
- (void) pushWithAnimation:(KCAViewController*)controller {
    controller.view.alpha = 0.0;
    [self navigationController].navigationBar.alpha = 0.0;
    [[self navigationController] pushViewController:controller animated:NO];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1.0];
    self.navigationController.navigationBar.alpha = 1.0;
    controller.view.alpha = 1.0;
    [UIView commitAnimations];
    self.navigationController.navigationBarHidden = controller.shouldHideToolbar;
}

- (IBAction) aboutPressed {
	[self pushWithAnimation:(aboutController)];
}
Maybe I'm doing some catastrophically wrong but it seems like there should be somewhere that I can switch which view is active when the page loads.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Zhentar posted:

Yes, I want to know what type it accepts. And whether or not it's an object or a primitive is what I want to know most, so that method doesn't help me (it also doesn't help if the key you are setting is nil...).

This is almost certainly not what you want to do, but the runtime can tell you whether a property takes a primitive or an object. Take a look at the Objective-C Runtime Programming Guide, in the Declared Properties section. You can get a type string (aka what you get out of @encode) for a property, which you would then have to parse for the information you're looking for.

Again, you probably don't want to do it this way, and you should look into NSValue boxing/unboxing and (if that doesn't work for you) key-value coding validation before you go parsing type strings.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Yodzilla posted:

Yeah looks like no dice. Here's what I have:

[a -loadView implementation]


Are you sure that code gets called?

Are you loading from a nib? If the view comes from a nib you'll get screwy results overriding -loadView and you're probably better off with -viewDidLoad:.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch

pokeyman posted:

Are you sure that code gets called?

Are you loading from a nib? If the view comes from a nib you'll get screwy results overriding -loadView and you're probably better off with -viewDidLoad:.

Yeah just tested it by writing to the console within loadView, it's definitely being called but not actually doing anything regarding switching views.

code:
 - (void)loadView {
     [super loadView];

     printf("loadView");

     UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
     if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight)
     {
         self.view = self.landscapeView;
     }
     else
     {
         self.view = self.portraitView;
     }
 }

- (void)viewDidLoad {
    [super viewDidLoad];
    
    printf("didLoad");

    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
    if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight)
    {
        self.view = self.landscapeView;
    }
    else
    {
        self.view = self.portraitView;
    }
}
Get me:

code:
-[UAAnalytics resetEventsDatabaseStatus] [Line 473] Oldest Event: 0.000000
loadViewdidLoad
So...yup still not rotating.

Should I just throw up all of my RootViewController and the view I'm trying to load's code? I really appreciate all of the help, I just feel so dumb and stuck right now.

Doc Block
Apr 15, 2003
Fun Shoe

Yodzilla posted:

Yeah just tested it by writing to the console within loadView, it's definitely being called but not actually doing anything regarding switching views.

code:
 - (void)loadView {
     [super loadView];

     printf("loadView");

     UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
     if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight)
     {
         self.view = self.landscapeView;
     }
     else
     {
         self.view = self.portraitView;
     }
 }

- (void)viewDidLoad {
    [super viewDidLoad];
    
    printf("didLoad");

    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
    if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight)
    {
        self.view = self.landscapeView;
    }
    else
    {
        self.view = self.portraitView;
    }
}
Get me:

code:
-[UAAnalytics resetEventsDatabaseStatus] [Line 473] Oldest Event: 0.000000
loadViewdidLoad
So...yup still not rotating.

Should I just throw up all of my RootViewController and the view I'm trying to load's code? I really appreciate all of the help, I just feel so dumb and stuck right now.

I know this isn't very helpful, but read Apple's View Controller Programming Guide.

Doc Block fucked around with this message at 01:55 on Jan 26, 2012

Zhentar
Sep 28, 2003

Brilliant Master Genius

pokeyman posted:

This is almost certainly not what you want to do, but the runtime can tell you whether a property takes a primitive or an object. Take a look at the Objective-C Runtime Programming Guide, in the Declared Properties section. You can get a type string (aka what you get out of @encode) for a property, which you would then have to parse for the information you're looking for.

That is what I was looking for originally, thank you.

Carthag Tuek
Oct 15, 2005

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



I'm subclassing an IKImageView, and I can't go -setOverlay:forType: during awakeFromNib, it appears to be too early. Fails with:

2012-01-26 02:13:22.865 Test[4071:1203] *** could not add '<CALayer: 0x101b38f20>' linkedTo 'kIKImageLayerType'

Works fine if I do it slightly delayed like this:

[self performSelector:@selector(setupOverlays) withObject:nil afterDelay:0.0f];

But that is such a giant hack. Any suggestions?

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch

Doc Block posted:

I know this isn't very helpful, but read Apple's View Controller Programming Guide.

Yeah I've been through it but I guess whatever I needed didn't click. It doesn't help that I only work in iOS every six months or so and I didn't write this app to begin with. :saddowns:


I get the feeling that I need to set the view I want as default to the view delegate programmatically and before the page even loads but I'm just not sure how to go about doing that.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Yodzilla posted:

I get the feeling that I need to set the view I want as default to the view delegate programmatically and before the page even loads but I'm just not sure how to go about doing that.

Set the UIViewController's view property?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Carthag posted:

I'm subclassing an IKImageView, and I can't go -setOverlay:forType: during awakeFromNib, it appears to be too early. Fails with:

2012-01-26 02:13:22.865 Test[4071:1203] *** could not add '<CALayer: 0x101b38f20>' linkedTo 'kIKImageLayerType'

Works fine if I do it slightly delayed like this:

[self performSelector:@selector(setupOverlays) withObject:nil afterDelay:0.0f];

But that is such a giant hack. Any suggestions?

For what it's worth, that's not actually slightly delayed so much as it'll happen on the next available iteration of the runloop. So it's more like a giant's little brother of a hack.

I'm curious whether the issue is waiting for the IKImageView to appear before dicking with its layer. If you make an IKImageView with code and then immediately add the layer do you get the same problem?

Either way, you could try subclassing some NSView method like -viewWillDraw and add your layer there?

Carthag Tuek
Oct 15, 2005

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



Yeah I know it's not terrible, I just need to read up on the life cycles of NSViews more I think. I tried googling, and I don't see a lot of people talking about that error, and those who do have conflicting solutions.

Anyway here's what I've spent the evening doing:


https://github.com/mikkelee/MEOverlayView

Basically you can set an overlayDelegate on an IKImageView and it'll show overlays as you specify in the delegate, including moving them around, adding/deleting, all the while telling the delegate what it's doing. Still some work to be done, and cleanup, but it works well enough for an initial commit.

Edit: Ignore the "update" button, that just jacks directly into "setupOverlays" and isn't really needed at the moment.

Carthag Tuek fucked around with this message at 03:35 on Jan 26, 2012

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Not exactly on topic, but why does your screenshot have pinstripes?

Carthag Tuek
Oct 15, 2005

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



I guess this is how Lion looks now? I haven't done anything to the window itself. Actually the Finder windows look like that too now that I look at them. I don't notice them day-to-day to be honest so I dunno if that is how they always look.

Anyway, I just realized that I need a good way for the delegate to let the view know that it has new info. I guess I'll have to look into notifications for that.

30 TO 50 FERAL HOG
Mar 2, 2005



If I want to show a view controller programmatically, do I have to define and implement my own init? I have created the view in interface builder, and would like to use it exactly how it is designed there. Should I just create an outlet in every class that is going to use it? Am I doing this completely the wrong way?

Analytic Engine
May 18, 2009

not the analytical engine
Forgive a simple question (it's a long thread), but what should I put in the business/organization form when registering a personal Apple Developer account? Also, should I make a seperate Apple ID for my coding account? Can you release iOS software under a different name than your Apple ID?

Doc Block
Apr 15, 2003
Fun Shoe

BiohazrD posted:

If I want to show a view controller programmatically, do I have to define and implement my own init? I have created the view in interface builder, and would like to use it exactly how it is designed there. Should I just create an outlet in every class that is going to use it? Am I doing this completely the wrong way?

You can just do
MyViewController *vc = [[MyViewController alloc] init], which should work if the nib name is the same as the viewcontroller. Otherwise you can use initWithNibName:bundle:, like this
MyViewController *vc = [[MyViewController alloc] initWithNibName:@"whatever.nib" bundle:nil]

What exactly are you trying to do?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

BiohazrD posted:

If I want to show a view controller programmatically, do I have to define and implement my own init? I have created the view in interface builder, and would like to use it exactly how it is designed there. Should I just create an outlet in every class that is going to use it? Am I doing this completely the wrong way?

Where's the view in Interface Builder (or I guess it's just Xcode) right now?

10 If the view's in its own nib, set the 'File's Owner' of the nib to be an instance of your view controller class (in the Identity inspector, set the class). Then hook up the File's Owner's -view outlet to the UIView in the nib. Now you can simply
code:
MyViewController *vc = [[MyViewController alloc] initWithNibName:@"SomeNib" bundle:nil];
with no need to implement your own -init methods.

If the view's not in its own nib, consider putting it in its own nib then GOTO 10. If that's not an option, things get trickier. If you are only going to use the view once, you can add an outlet to whatever object in the nib is going to show the view, hook the view up to that outlet, then you can
code:
MyViewController *vc = [[MyViewController alloc] init];
vc.view = self.viewOutlet;
However, this is kind of lame, because you should really assign a copy of the view to each new view controller that wants it. You can't (in Mac OS X anyway, I presume iOS too?) copy a view simply by sending -copy, but you can get around that using NSCoding.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Analytic Engine posted:

Forgive a simple question (it's a long thread), but what should I put in the business/organization form when registering a personal Apple Developer account? Also, should I make a seperate Apple ID for my coding account? Can you release iOS software under a different name than your Apple ID?

The business/organization form field is what shows up in the App Store as "for sale by". Lots of individuals use their own name, or perhaps the name of their incorporated company if they have one. As far as I know you can put whatever you want in this field, but I could very well be wrong here as I've never tried anything fancy.

I don't see any real benefit to have a separate Apple ID just for App Store use. If you find it convenient to keep them separate, go for it.

30 TO 50 FERAL HOG
Mar 2, 2005



pokeyman posted:

code:
MyViewController *vc = [[MyViewController alloc] initWithNibName:@"SomeNib" bundle:nil];

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.

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

Lumpy posted:

Core Data Question:

I'm syncing data with a server: I want to create new managed objects if they don't exist, and update ones if the modified date for the entity on the server is newer than the one on the device. I've read through this: http://developer.apple.com/library/.../TP40003174-SW1

Since I dont' have any relationship data here, it seems that their suggestion to "..create managed objects for the entire set and weed out (delete) any duplicates before save using a single large IN predicate" would be appropriate for adding new people. Question is, how do I do that? how do I then get the duplicates and update based on that timestamp?

Core Data baffles me.

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).

Carthag Tuek
Oct 15, 2005

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



My OverlayView is nearing the point where I'm satisfied with it: https://github.com/mikkelee/MEOverlayView

Anyone want to give it a spin and see if it works properly for them? Also ideas for features/bug reports are welcome.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

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 haven't touched storyboards at all, so I'm just as lost. Sorry. If nobody else can help I'll poke around and see what I can do in the next couple days.

Adbot
ADBOT LOVES YOU

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
Yeah I have a feeling that storyboards are the way they're really trying to lead people into creating basic user interfaces. I think I might need to rewrite this app I'm currently working on to use them.

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