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

Toady posted:

It's not proper design to treat the app delegate as an Everything Container, but it's common anyway.

Yeah I'm guilty of this, but my rule of thumb is that stored objects have to be related to the app lifecycle in some way. So my audio engine is housed there because it is turned on / off for app state changes. Same with my CMDeviceMotion instance and master UITabBarController.

The header gets peppered with a bunch of readonly properties and a few on / off switch methods related to those objects, but it's not that unreasonable.

edit: oh and my open UIDocument. No idea where that would be better stored.

Adbot
ADBOT LOVES YOU

Doh004
Apr 22, 2007

Mmmmm Donuts...
I'm cool with a core component of the application living there as long as a ton of logic doesn't exist in the actual app delegate.

Toady
Jan 12, 2009

It's reasonable to have top-level components that are tied to the application's life cycle or don't have any other owner. The problem is treating the delegate as an application-wide storehouse that everything goes through +sharedApplication to access, which can be difficult to maintain and refactor. iOS developers are notorious for this.

Axiem
Oct 19, 2005

I want to leave my mind blank, but I'm terrified of what will happen if I do
The strategy we are using at my day job is that we have an ApplicationDependencies object. This is initialized as a result of the ApplicationDelegate. The job of the ApplicationDependencies on initialization is to initialize all of the various things like the database connection, and so on. The ApplicationDelegate tends to be passed to the main View Controllers, but when anything is instantiated, it is just handed what things in the ApplicationDependencies it needs.

From a testing perspective, each object only knows about the dependencies it has, and those can be easily mocked.

Though aside from a logger, there are very few things your entire application actually needs, and if you're thinking of making say, your database connection a singleton, you may want to reconsider your architecture from an MVC/MVP perspective. When you build the model, pass in the database connection object (or better, a facade for the things you need to do with the database). That facade can be built up in the ApplicationDependencies.

While at a certain point I'm not entirely happy with the ApplicationDependencies strategy (still feels too much like a singleton), it works pretty well so long as you keep your classes small. (And if you don't keep your classes small, then I have no good advice for you, because large classes are in my opinion generally antithetical to good code).

Doc Block
Apr 15, 2003
Fun Shoe

Snapchat A Titty posted:

What's wrong with this snippet?

Objective-C code:

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

int main(int argc, char *argv[]) 
{
	NSLog(@"Starting...");
	
	NSError *error = nil;
	ITLibrary *library = [ITLibrary libraryWithAPIVersion:@"1.0" error:&error];
	
	if (library) {
		NSLog(@"Opened library with %lu items in %lu playlists (location: %@).", [library.allMediaItems count], [library.allPlaylists count], library.musicFolderLocation);
		
		return 0;
	} else {
		NSLog(@"Error: %@", error);
		
		return error.code;
	}
}

Compiled with clang -framework Foundation -framework iTunesLibrary -o itunes itunes.m

Output:

pre:
2015-03-18 19:49:06.844 itunes[3294:89688] Starting...
2015-03-18 19:49:07.750 itunes[3294:89688] Opened library with 0 items in 0 playlists (location: (null)).

It's like it doesn't find the library file and just inits with an empty library? Docs here: https://developer.apple.com/library/mac/documentation/iTunesLibrary/Reference/ITLibrary_reference/

No idea, but a couple points:
- you need an auto release pool. @autoreleasepool { } around the outermost scope in your main() function.
- have you tried printing out the library object? NSLog(@"%@", library);

Doctor w-rw-rw-
Jun 24, 2008

geera posted:

Is it generally considered OK to use the app delegate as a universal holding area for objects you might need to access anywhere in the app (like a database connection, logger, etc)? Are singletons a reasonable alternative for some of those shared purposes? I've tinkered with iOS development and I've been wondering where people put commonly-used objects like that.

I use a different pattern, where I have a Session Service, Session Provider, and Session object. The Session object can only be created by the Session Service, and can only be accessed from a Session Provider. The Session Provider is instantiated by the owning scope, i.e. whatever retains it, like a UIViewController or a UIView. When it's initialized, it subscribes to the Session Service; when it's dealloc'd it unsubscribes (aka RAII).

That's how I've managed to not need any global state (on a language/ObjC runtime level) except for the Session Service (which is set up by the app delegate). I've also made it so that the initializer for the provider has an update block, so when someone i.e. logs in / logs out, literally everything that cares will be triggered by the login and update itself. But as a convenience, you can just access the .session property on the provider. You can also create one temporarily to only last until it falls out of (lexical) scope and gets cleaned up. When the view or the view controller dies, so too does its subscription, wherever it is.

Been working fantastically for me so far.

Doctor w-rw-rw- fucked around with this message at 02:00 on Mar 19, 2015

kode54
Nov 26, 2007

aka kuroshi
Fun Shoe
I'm going to break a bit of NDA to say that installing 10.10.3 seed broke my code signing process, which was to build everything without signing as an archive, then my update script would run codesign --force --deep on the whole bundle after copying it to a temporary location. Now codesign crashes itself on that.

It also revealed a lot about my project that was broken when I was attempting to fix it. First I enabled code signing on release builds for all of my frameworks and bundles, and manually signed all of the third party .dylib files I use. Then I noticed a bunch of the original PlugIn .bundle projects I imported when I originally took over the project were spuriously copying headers into the .bundles, which is a no-no, because headers can only be signed in frameworks. Then I noticed the third party framework I was using for Growl, supplied by the official developer, had an obsolete and therefore broken signature on it, so I replaced the signature with my own instead.

Then I changed my update script, which modifies the main .app bundle's Info.plist to insert the Mercurial revision number and short hash string into the version string for the application, so that it merely shallow force resigns the bundle, instead of attempting the crashable deep sign.

Also, because my original signing practice used a signing script that force resigned the whole app bundle if spctl -a failed, without any limit for failures, due to a deep signing issue I already had in the past (lovingly called fucking_sign_it.sh) it would crash in the middle of the signing, dropping a .cstemp file in a random place where it failed, then it would try to sign and fail somewhere else, dropping another .cstemp file somewhere. Resulting mess would spill about five or six temp files across the bundle, then hang on the last attempt.

Oh well, it's probably for the better that I do it this way anyway.

Carthag Tuek
Oct 15, 2005

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



Doc Block posted:

No idea, but a couple points:
- you need an auto release pool. @autoreleasepool { } around the outermost scope in your main() function.
- have you tried printing out the library object? NSLog(@"%@", library);

I've found this, appears I need to sign the app. Maybe some other day :effort:

http://stackoverflow.com/questions/16597284/using-new-ituneslibrary-framework-to-access-itunes-library-on-mac-os-x

lord funk
Feb 16, 2004

Dumb question, but if you go with Metal for graphics, you're only supporting A7 chips and higher. What happens in the store if someone gets your app with an <A7 device? Can they download it? Are you supposed to gracefully switch to OpenGL for them?

Doc Block
Apr 15, 2003
Fun Shoe
You can put in Info.plist that your app requires Metal.

You could also only ship a 64-bit binary, since Metal isn't supported on 32-bit devices.

But it'd sure be nice if your app didn't require Metal just yet. Which means failing over to OpenGL if it can't initialize a Metal context (which would only happen on an unsupported device).

lord funk
Feb 16, 2004

Doc Block posted:

You can put in Info.plist that your app requires Metal.

You could also only ship a 64-bit binary, since Metal isn't supported on 32-bit devices.
Cool, thanks.

Doc Block posted:

But it'd sure be nice if your app didn't require Metal just yet. Which means failing over to OpenGL if it can't initialize a Metal context (which would only happen on an unsupported device).

Of course, but with limited resources the idea of using only one GPU framework is attractive. Plus I'm always looking at a long development period, so given a bit more time it wouldn't sting as much.

Doc Block
Apr 15, 2003
Fun Shoe
Maybe, but people keep their iPads way longer than they keep their iPhones.

lord funk
Feb 16, 2004

Doc Block posted:

Maybe, but people keep their iPads way longer than they keep their iPhones.

If making a Metal-only app gets just one of them to burn their iPad 3, then it will all be worth it.

Doc Block
Apr 15, 2003
Fun Shoe
I still use an iPad 3 :mad:

Fate Accomplice
Nov 30, 2006




Doc Block posted:

I still use an iPad 3 :mad:

I own and use a launch week iPad 1. as far as I'm concerned, Apple canceled iOS after 5.1.4, and we're all better off for it.

Doc Block
Apr 15, 2003
Fun Shoe
I'm not thrilled about all of it, and iOS definitely needs a Snow Leopard-style polish release (including a revisit of some of the My First User Interface Design and My First Adobe Illustrator Project stuff that came in with iOS 7), but iOS 8 is pretty good.

Plus, as a developer, things are vastly better than the iOS 5 days in almost every respect.

brap
Aug 23, 2004

Grimey Drawer
Snow Yosemite is needed as well.

UraniumAnchor
May 21, 2006

Not a walrus.
Is there a way to retrieve standard iconography? Specifically I want to grab the texture for the "share" button and load it into an OpenGL texture. Or am I better off just taking a screenshot and faking it?

Froist
Jun 6, 2004

UraniumAnchor posted:

Is there a way to retrieve standard iconography? Specifically I want to grab the texture for the "share" button and load it into an OpenGL texture. Or am I better off just taking a screenshot and faking it?

I've not seen a way of grabbing the image at runtime, but I've used iOS Artwork Extractor which will dump all the image resources from the simulator. This way you can at least bundle the real image with your app rather than relying on screenshots.

lord funk
Feb 16, 2004

Doc Block posted:

I still use an iPad 3 :mad:

What I would really like to see is the Mac equivalent of this graph. Like using an iPad 3 would be the same as using a Powerbook G3 or something.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

lord funk posted:

What I would really like to see is the Mac equivalent of this graph. Like using an iPad 3 would be the same as using a Powerbook G3 or something.

It's probably not that accurate, but Mactracker has the iPad 3 Geekbenching 760, which is first beaten by a 1.5 GHz Powerbook G4 (807).

lord funk
Feb 16, 2004

carry on then posted:

It's probably not that accurate, but Mactracker has the iPad 3 Geekbenching 760, which is first beaten by a 1.5 GHz Powerbook G4 (807).

Right but the difference between the iPad 3 and the Air 2 is around 1/7 to 1/10 according to this. So I want to know which laptop is 1/10 the speed of the new Macbook Pro, for example.

edit: and the Mac chart doesn't seem to go that low.

Doh004
Apr 22, 2007

Mmmmm Donuts...
Anyone else use Xcode server and bots to run CI? If so, anyone know how to get environment variables in the trigger? I want to get a variable from a config file in the repo into the script.

Doctor w-rw-rw-
Jun 24, 2008
Anyone else going to f8 tomorrow? Excited for the iOS talks.

lord funk
Feb 16, 2004

TC-11 2.0 released today! :dance:



Some codes so you guys can check it out. :)

ARAJFTRW6YW6
7HNAKXFKLRAT
LPFPLHNYXMW6
R6FMJ3PRPE9X
N6RH4FT7KXH4

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Congrats! Will play with it later tonight.

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

Doctor w-rw-rw- posted:

Anyone else going to f8 tomorrow? Excited for the iOS talks.

I'm assuming you're quite pleased about this one?

quote:

To tackle this challenge, we wanted a better abstraction. We drew inspiration from React and its functional reactive programming model for building UI and made a native, Objective-C++ library called ComponentKit which is now used to render News Feed in the Facebook iOS app.

Today we're very excited to announce that we are making ComponentKit open source!

https://code.facebook.com/posts/1415586422080360/introducing-componentkit-functional-and-declarative-ui-on-ios

dc3k
Feb 18, 2003

what.
^^^ oh my god this would completely solve all of the problems I'm currently having with scroll performance via overly complicated UI components written by assholes

brap
Aug 23, 2004

Grimey Drawer
Is it really necessary to use "Objective-C++" because that sounds like some wacky poo poo.
edit: this page explains it http://componentkit.org/docs/why-cpp.html but I still kinda wish they had built it for swift or something, even though swift's short existence and quirks so far can be difficult-- they've precluded swift interop by incorporating c++.

brap fucked around with this message at 02:46 on Mar 26, 2015

xpander
Sep 2, 2004

lord funk posted:

TC-11 2.0 released today! :dance:



Some codes so you guys can check it out. :)

ARAJFTRW6YW6
7HNAKXFKLRAT
LPFPLHNYXMW6
R6FMJ3PRPE9X
N6RH4FT7KXH4

Claimed the last one, as I was feeling lazy and didn't want to have to enter more than one. I've been meaning to check this out for a while!

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

fleshweasel posted:

Is it really necessary to use "Objective-C++" because that sounds like some wacky poo poo.
edit: this page explains it http://componentkit.org/docs/why-cpp.html but I still kinda wish they had built it for swift or something, even though swift's short existence and quirks so far can be difficult-- they've precluded swift interop by incorporating c++.

That's the biggest disappointment; the platform language is Objective-C, not Objective-C++. All of the things they cite have clear alternatives or workarounds that are idiomatic. I think the people leading the project just like C++ and decided to use it, then came up with a post-hoc rationalization.

To my knowledge no one has come up with a decent implementation for doing powerful animation with React-style UI frameworks and it doesn't look like they solved that problem here either.

edit: I like the framework OK and I like React a lot too; they just feel like stepping stones toward a much better UI framework design that we haven't reached yet.

Doctor w-rw-rw-
Jun 24, 2008

fleshweasel posted:

Is it really necessary to use "Objective-C++" because that sounds like some wacky poo poo.
edit: this page explains it http://componentkit.org/docs/why-cpp.html but I still kinda wish they had built it for swift or something, even though swift's short existence and quirks so far can be difficult-- they've precluded swift interop by incorporating c++.
I recall something like it, or the ideas, at least, starting to form towards the end of 2013, as the feed cell height bug they talk about happened that summer/fall. By the time Swift was announced, much less by the time it hit 1.0, Components was almost certainly already well underway.

For a project that prioritizes predictability, performance, and stability, and wants to reach the maximum number of devices (note that they mentioned Feed at 60fps on iPhone 4), Swift was, is, and will remain a terrible choice up until the point that a stable version of it can run well on the oldest iOS device supporting the current OS revision minus 1. Don't get me wrong, I like the language, but the merits of Swift do not yet outweigh its lack of ubiquity and C++'s decades of improvements.

Ender.uNF posted:

That's the biggest disappointment; the platform language is Objective-C, not Objective-C++. All of the things they cite have clear alternatives or workarounds that are idiomatic. I think the people leading the project just like C++ and decided to use it, then came up with a post-hoc rationalization.
I asked this at the tail end of the f8 presentation.
Stack allocated objects, syntax, and type-safety. Stack allocated objects is a big deal.

Objective-C++ was already used in several places in the fbios codebases. I occasionally use it in mine. If you can do Objective-C, you can do Objective-C++, and while there may be zero pressing need to use it, there's no good reason to totally avoid it except in the case that your codebase is so large it would blow up compile times by a noticeable number of minutes. Avoiding it means you're avoiding good poo poo to help you program better.

Personally (and to harp on this yet again), the argument that I accept most quickly as to why it uses C++ is that it can then stack allocate class instances. A small stack allocated C++ class vs. a NSObject is a no-brainer if you're making and destroying butt-tons of small classes all the time.

Doctor w-rw-rw- fucked around with this message at 05:17 on Mar 26, 2015

Glimm
Jul 27, 2005

Time is only gonna pass you by

Cool, React Native released too:
https://github.com/facebook/react-native

Doc Block
Apr 15, 2003
Fun Shoe

brap
Aug 23, 2004

Grimey Drawer
As true a point as that is, is it this steve streza speaking?

Doc Block
Apr 15, 2003
Fun Shoe
No idea. I just thought it was a funny, relevant thing that I only saw because Marco Arment retweeted it.

I have no idea who the guy in the picture you posted is, either.

Doctor w-rw-rw-
Jun 24, 2008

ASDK is /probably/ dead, dying, or if it's neither, in limbo, so that leaves React Native and Components. I'd take Objective-C++ over Javascript in a heartbeat. Seems like an easy choice - if you don't like using/want to use Javascript, use Components.

Also, declarative layout FTW, so you kind of win either way with React Native or Components.

mrbass21
Feb 1, 2009
Is there some display controller out there that will allow me to display big files? I have a ~270 MB PDF that I'm trying to display for the user and my applications memory usage is low (20 MB or so), but as the UIDocumentInteractionController loads the PDF, I get memory warnings, and then the controller stops loading the PDF (but doesn't crash). The file opens while running in simulator, but that uses system memory.

I tried in GoogleDrive and Dropbox to see if other programs had trouble with it. GoogleDrive crashes trying to open it, and DropBox actually does display the file.

Is there some controller out there that can handle really large files, or did DropBox just write their own?

Kallikrates
Jul 7, 2002
Pro Lurker
I would say that it's more a function of the view displaying the PDF than the containing controller. For something that large I would make sure it's a CATiledLayer Backed view, theoretically it should do the work for you of only reading the visible chunks into memory. if not there is an api for digging into that.

Adbot
ADBOT LOVES YOU

mrbass21
Feb 1, 2009

Kallikrates posted:

I would say that it's more a function of the view displaying the PDF than the containing controller. For something that large I would make sure it's a CATiledLayer Backed view, theoretically it should do the work for you of only reading the visible chunks into memory. if not there is an api for digging into that.

I need users to be able to open many file types (iWorks, MS Office, PDF, Pictures, anything iOS supports). Will that approach work for all files? It seemed like for the CATiledLayer to work I had to write some code to handle a PDF and it might not work for everything. Is that accurate or "Google harder, my son"?

I assume for PDFs and Images, I could take that approach, but all the others would need custom controllers to display them? The project is in it's early phase and I just need something that will work for the majority of cases as I go. I can come back to work on "What if the user tries to view a file that's stupid large".

mrbass21 fucked around with this message at 22:22 on Apr 1, 2015

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