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
Axiem
Oct 19, 2005

I want to leave my mind blank, but I'm terrified of what will happen if I do
This is probably indicative of real ignorance on my part of what's going on here, but if I have a storyboard with various views and transitions in it, how would I go about converting that all to code? I kinda want to move away from the nib files (for the reasons noted), but it just seems a daunting process.

Adbot
ADBOT LOVES YOU

Doctor w-rw-rw-
Jun 24, 2008

kitten smoothie posted:

Do any complicated projects use interface builder at all?
IMO, no, but xibs are at least better than storyboards, which are slow. They're easier to localize on account of being files, but in practice this wasn't a huge concern.

Axiem posted:

This is probably indicative of real ignorance on my part of what's going on here, but if I have a storyboard with various views and transitions in it, how would I go about converting that all to code? I kinda want to move away from the nib files (for the reasons noted), but it just seems a daunting process.

When you decide to switch to code:
Step 1: Stop making new things in storyboards. Everything new, you should be creating in code. This means instantiating and adding your views in loadView and laying them out in viewWillLayoutSubviews.
Step 2: Make sure your application navigation is done in code. I'm not too familiar with segues myself, unfortunately, so I can't give nuanced advice here.
Step 3: Start migrating view controllers bit by bit. Use +[UIStoryboard storyboardWithName:bundle:] to get the storyboard and -[UIStoryboard instantiateViewControllerWithIdentifier:] to instantiate the view controllers you need.

Doctor w-rw-rw- fucked around with this message at 23:27 on Feb 15, 2014

Doc Block
Apr 15, 2003
Fun Shoe

kitten smoothie posted:

Also it was infuriating that just the very act of opening a xib file -- not changing the design -- was enough to change the file.

Set the specific version of Xcode/IB for the XIB to use and this will stop happening IIRC.

The reason it does this is because the XIB contains the version of Xcode it's supposed to be compatible with, and the default is "Current version - 1", so it updates it when you upgrade Xcode and then open the XIB in the new version.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

kitten smoothie posted:

Do any complicated projects use interface builder at all?

Absolutely. The whole "I don't use IB" thing only really started in earnest after the release of the iPhone SDK, when lots of developers used to platforms whose UI tools did (poor) code generation switched to developing for it.

quote:

And yeah merging xcode project files within a team was annoying enough at times so the less auto generated magical files to deal with, the better.

What have you found difficult about it? The Xcode project file format is designed pretty explicitly to be mergeable when multiple people have made changes to the file, in the same way source code is. It will also have conflicts just like source code: If two people add code to the same place in a method, one of them will have to resolve that conflict. Same thing with Xcode projects, if two people add a file to the end of a group, one of you will have to tell Xcode which one is first and which is second.

There was a thread on the xcode-users list a year and a bit ago you might find informative.

lord funk
Feb 16, 2004

Ha ha, nope:

code:
- (void)dealloc {
    [self addObserver:self forKeyPath:@"noteFilter" options:NSKeyValueObservingOptionInitial context:nil];
}

Toady
Jan 12, 2009

eschaton posted:

Absolutely. The whole "I don't use IB" thing only really started in earnest after the release of the iPhone SDK, when lots of developers used to platforms whose UI tools did (poor) code generation switched to developing for it.

Littering files with unnecessary layout code feels dirty, so I can't help but use IB as much as I can. However, I'm probably more comfortable with it than new iPhone developers were because I was using Cocoa since before the iPhone SDK came out.

FlashBangBob
Jul 5, 2007

BLAM! Internet Found!
So I'm still relatively new to this thread and objective-c in general, but I'm wondering what the standards are for handling time zone conversions with NSDate. From what I've read, NSDate doesn't care about timezone, its simply just a date in time. So my question is how to approach the timezone offset support to do accurate date time comparisons from server to local phone. The current solution is to use NSDateFormatter to take the NSDate into a string, convert it to the local time zone, and then convert the string back into an NSDate. Is there a better standard for this? Is it best to create a class wrapper around NSDate to handle the timezone conversion in that fashion?

ManicJason
Oct 27, 2003

He doesn't really stop the puck, but he scares the hell out of the other team.
It's always best to keep all data in UTC and do the time zone conversion when displaying. You'll have to be a bit more specific as to why that won't work for you.

Doctor w-rw-rw-
Jun 24, 2008

ManicJason posted:

It's always best to keep all data in UTC and do the time zone conversion when displaying. You'll have to be a bit more specific as to why that won't work for you.

Seconded. NSDates are GMT. Format them according to timezone, but don't store them according to timezone.

FlashBangBob
Jul 5, 2007

BLAM! Internet Found!

ManicJason posted:

It's always best to keep all data in UTC and do the time zone conversion when displaying. You'll have to be a bit more specific as to why that won't work for you.

This is a fine answer. The standard practice is what I was looking for and UTC across the board & converting at display time makes a lot of sense. Thanks.

kitten smoothie
Dec 29, 2001

Doctor w-rw-rw- posted:

Seconded. NSDates are GMT. Format them according to timezone, but don't store them according to timezone.

And be careful when parsing dates from external services, make sure to set a sensible locale on your date formatter when parsing.

https://developer.apple.com/library/ios/qa/qa1480/_index.html

This caused us a weird heisenbug with one particular user in a foreign country. They had their device set to the en_GB locale, which automatically sets 24 hour time display, so they also went into the time display settings and turned on 12-hour time display. One of our team members is based in the UK and has no problems, but she didn't have the AM/PM override set, and apparently that's the critical factor.

Enabling 12-hour time display in a locale that defaults to 24-hour display has the effect of making the NSDateFormatter automatically rewrite format strings to include AM/PM and so it would fail to parse the times we were passing it, despite them being totally kosher dates in UTC. You have to set a locale on your NSDateFormatter that would be a locale where your date makes sense, or else it will inherit all the characteristics of the default locale.

ptier
Jul 2, 2007

Back off man, I'm a scientist.
Pillbug

ptier posted:

**rambling about SceneKit**

So after doing the basic research , it's all the same kinds of matrix manipulation you would use in Core Animation for 3D views. I realize now I didn't know enough to know what I needed to ask questions about. After I posted I took a closer look at Core Animation and found this really good tutorial about 3D in Core Animation if anyone is interested:

http://www.thinkandbuild.it/introduction-to-3d-drawing-in-core-animation-part-2/

It really helped with my situation. This thread has been pretty enjoyable to keep up with, and has already taught me a lot about where to look.

Also if anyone hasn't tried out Dash, you should. It's a pretty great documentation viewer.

Hughlander
May 11, 2005

ptier posted:

Also if anyone hasn't tried out Dash, you should. It's a pretty great documentation viewer.

It's great but it's :10bux: great not :20bux: great. I keep waiting to see if the IAP will go on sale.

ptier
Jul 2, 2007

Back off man, I'm a scientist.
Pillbug

Hughlander posted:

It's great but it's :10bux: great not :20bux: great. I keep waiting to see if the IAP will go on sale.

I am just using the free version for fast fast text search. I don't really need to super cool guy features yet.

Hughlander
May 11, 2005

ptier posted:

I am just using the free version for fast fast text search. I don't really need to super cool guy features yet.

Ah you'll quickly reach a point where you need to have it have focus for 8 seconds before a search and it's no longer fast fast.

Doctor w-rw-rw-
Jun 24, 2008

Hughlander posted:

It's great but it's :10bux: great not :20bux: great. I keep waiting to see if the IAP will go on sale.

I bought it during a macupdate sale, IIRC. If you're making enough money as a developer to where the :10bux: delta is a negligible portion of your income, the productivity increase, while modest, is worth the :20bux:. At least, it was for me.

Carthag Tuek
Oct 15, 2005

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



FlashBangBob posted:

This is a fine answer. The standard practice is what I was looking for and UTC across the board & converting at display time makes a lot of sense. Thanks.

For me it helps to think of NSDate as an opaque value that should never be displayed except through a properly configured NSDateFormatter.

Hughlander
May 11, 2005

Doctor w-rw-rw- posted:

I bought it during a macupdate sale, IIRC. If you're making enough money as a developer to where the :10bux: delta is a negligible portion of your income, the productivity increase, while modest, is worth the :20bux:. At least, it was for me.

Let me know next time there's one, I have no idea what that is or what they're schedule is. Basically I'm being worn down on it. It's in an odd category:

- It's not enough to be worth filling out a reimbursement for work.
- I don't do enough iOS development at home to want to spend 20$ on it
- I feel it's really worth 10-15.
- There's no guarantee that my next job I'll even have an OSX machine so I'd just be throwing it away from 1 & 2.

Honestly, I've spent more time and effort thinking about and justifying this that I logically should just buy it, but I'm being irrationally stubborn at the price point.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Hughlander posted:

- I don't do enough iOS development at home to want to spend 20$ on it

It also knows about docs for OS X, C and C++ stdlibs, man pages, Ruby and gems, Erlang, and CSS. And I think you can add more.

LP0 ON FIRE
Jan 25, 2006

beep boop
More Cocos2D 2.1 upgrade problems.. just knocking them out one at a time. Right now I'm having issues with object's y positions (coming from a tmx map) with SD vs HD (retina). In SD it is fine, and works the way it always used to, but in HD the y position is totally off.

code:
CCTMXObjectGroup *objects = [theMap objectGroupNamed:@"oj"];
		NSMutableDictionary *startPoint = [objects objectNamed:@"SaveStation"];		
		
		int x = [[startPoint valueForKey:@"x"] intValue];
		int y = [[startPoint valueForKey:@"y"] intValue]; 

		NSLog(@"startPoint = %@", startPoint);
		
		NSLog(@"x = %i",x); // gives me 304
		NSLog(@"y = %i",y); // gives me 1456 instead of 336.
Anyone have an idea why?

EDIT

Okay solved.. this thread pin pointed it: http://www.cocos2d-iphone.org/forums/topic/weird-values-from-valueforkey-when-parsing-tmx/

CCTMXXMLParser.m is referencing the tile height value from the HD map in literal pixels instead of points!

code:
// Y
		value = [attributeDict objectForKey:@"y"];
		if( value )  {
		int y = [value intValue] + objectGroup.positionOffset.y;

			// Correct y position. (Tiled uses Flipped, cocos2d uses Standard)
			y = (_mapSize.height * _tileSize.height) - y - [[attributeDict objectForKey:@"height"] intValue];
			[dict setObject:[NSNumber numberWithInt:y] forKey:@"y"];
		}


_tileSize.height will return 32. So I need to have it use a tile size of 16 instead of 32.

LP0 ON FIRE fucked around with this message at 19:34 on Feb 17, 2014

Toady
Jan 12, 2009

FlashBangBob posted:

So I'm still relatively new to this thread and objective-c in general, but I'm wondering what the standards are for handling time zone conversions with NSDate. From what I've read, NSDate doesn't care about timezone, its simply just a date in time.

My understanding is that NSDate is implemented as a given number of seconds since 2001-1-1 00:00 UTC.

haveblue
Aug 15, 2005



Toilet Rascal

Toady posted:

My understanding is that NSDate is a wrapper around the number of seconds since 2001-1-1 00:00 UTC.

Yes. NSDate is the model object, NSDateFormatter handles presentation, and NSCalendar does calculations within timekeeping systems.

Doctor w-rw-rw-
Jun 24, 2008

Toady posted:

My understanding is that NSDate is implemented as a given number of seconds since 2001-1-1 00:00 UTC.

:spergin: GMT, which is not the same timezone as UTC.

Sinestro
Oct 31, 2010

The perfect day needs the perfect set of wheels.
Time is a goddamn horror. There shall be exactly one time worldwide, in one format. Those who resist will need to be reeducated.

Axiem
Oct 19, 2005

I want to leave my mind blank, but I'm terrified of what will happen if I do

Doctor w-rw-rw- posted:

:spergin: GMT, which is not the same timezone as UTC.

Any idea why they chose GMT instead of UTC, when pretty much everything in time zones is based on UTC?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Doctor w-rw-rw- posted:

:spergin: GMT, which is not the same timezone as UTC.

Also note that "unix time" is neither GMT nor UTC!

Axiem posted:

Any idea why they chose GMT instead of UTC, when pretty much everything in time zones is based on UTC?

I'll wager a guess: NeXTSTEP followed the lead of extant Unixes and picked GMT, then OS X followed the grand tradition of bumping the epoch to the year of your release date, and from then either nobody bothered to change it, nobody could agree on what to change it to, or everybody agreed that changing it was just as confusing as not.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

pokeyman posted:

I'll wager a guess: NeXTSTEP followed the lead of extant Unixes and picked GMT, then OS X followed the grand tradition of bumping the epoch to the year of your release date,

Sort of, except NeXT always used 1/1/2000 GMT as the basis for NSTimeInterval. I'm not sure if NEXTSTEP had an equivalent type in the pre-Foundation days, but by at least EOF 1.1 or 1.2 (1992 or so) it was in its present form.

Looking at some NEXTSTEP 3.3 stuff, it looks like NSDate didn't have any pre-Foundation equivalent, even DBKit didn't have anything like it. I think NEXTSTEP just expected developers to just use the ANSI C date/time functions, just as it used C strings.

eschaton fucked around with this message at 05:34 on Feb 18, 2014

Doc Block
Apr 15, 2003
Fun Shoe
Wait, an OS that came out before the year 2000 used 1/1/2000 as its epoch?

haveblue
Aug 15, 2005



Toilet Rascal

Doc Block posted:

Wait, an OS that came out before the year 2000 used 1/1/2000 as its epoch?

The epoch starts in 2001, actually. NSTimeInterval is signed (it's really a double), so it has no problem representing dates before the epoch.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

eschaton posted:

Sort of, except NeXT always used 1/1/2000 GMT as the basis for NSTimeInterval. I'm not sure if NEXTSTEP had an equivalent type in the pre-Foundation days, but by at least EOF 1.1 or 1.2 (1992 or so) it was in its present form.

Looking at some NEXTSTEP 3.3 stuff, it looks like NSDate didn't have any pre-Foundation equivalent, even DBKit didn't have anything like it. I think NEXTSTEP just expected developers to just use the ANSI C date/time functions, just as it used C strings.

That's really cool. Where's a decent place to find old manuals and docs? I had a hard time googling for stuff.

Hughlander
May 11, 2005

What's the API that controls what appears on the lock screen when you first wake it? Like gives a preview of e-mail and tells you that in 4:23 your snooze will fire again?

haveblue
Aug 15, 2005



Toilet Rascal

Hughlander posted:

What's the API that controls what appears on the lock screen when you first wake it? Like gives a preview of e-mail and tells you that in 4:23 your snooze will fire again?

The email previews are notifications (local or network). The snooze warning and other custom things is something that only Apple can do.

Hughlander
May 11, 2005

haveblue posted:

The email previews are notifications (local or network). The snooze warning and other custom things is something that only Apple can do.

I didn't think they were local notifications because they will show like the title and then be "Hang on we're pulling more from the server" then update with the first few lines of the body.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

They're push notifications same as any other, right? The lock screen handles what it shows on its own, but notifications can be revoked, can't they?

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

pokeyman posted:

That's really cool. Where's a decent place to find old manuals and docs? I had a hard time googling for stuff.

I just found converted NEXTSTEP 3.3 docs online. Otherwise a lot of that stuff was installed for use by Digital Librarian and not in any sort of separate format.

Edit: There were print versions too but those may be getting rare now.

haveblue
Aug 15, 2005



Toilet Rascal
Something I wish Apple would fix (or someone to tell me a workaround for):

Type in header:

code:
-(IBAction)doSomething:(id)sender;
Start typing in implementation:

code:
-(IBA[return]
autocompletes to:

code:
-(IBAction)<selector>:(id)sender
Continue typing method name:

code:
-(IBAction)doS[return]:(id)sender
autocompletes to:

code:
-(IBAction)clickSomething:(id)sender:(id)sender

Kallikrates
Jul 7, 2002
Pro Lurker
I've slowly switched to:
code:
//typing
- do...[select auto complete]

Hughlander
May 11, 2005

Workaround: install AppCode

HaB
Jan 5, 2001

What are the odds?

Hughlander posted:

Workaround: install AppCode

Am I understanding this right? I installed AppCode for the 30 day trial. Double clicking either a Storyboard or a XIB (from within AppCode) opens xcode.

Uhhh....

I see now this is the intended behavior. Um. That's.....irksome.

HaB fucked around with this message at 21:27 on Feb 20, 2014

Adbot
ADBOT LOVES YOU

Hughlander
May 11, 2005

HaB posted:

Am I understanding this right? I installed AppCode for the 30 day trial. Double clicking either a Storyboard or a XIB (from within AppCode) opens xcode.

Uhhh....

I see now this is the intended behavior. Um. That's.....irksome.

Yes, but none of the code I write have storyboards or XIBs so it's not much of an issue for me. (There's a preview with their own XIB editor I believe.) Just try out the control-space and shift-control-space autocompletes. Or even the test runner!

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