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
Doc Block
Apr 15, 2003
Fun Shoe
I have a dumb question: given a table of the frequency of letters in the English alphabet, what's the best way to randomly select one based on the letter frequency? What I was going to do was just make a big array of letters, with each letter inserted arraySize * currentLetterFrequency number of times, and then just randomly select an array index with arc4random_uniform().

Is there a better way? Should I even bother with a weighted random number for choosing letters (this is for a word game)? Using Cornell University's letter frequency table, the letter Z would only appear 70 times in an array of 100k entries (0.07% frequency).

Another question: is there a better way to determine if a word entered by the player is an actual English word than by just throwing a huge list of all English words as separate strings into an NSSet (or NSDictionary) and then calling -member:?

Adbot
ADBOT LOVES YOU

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

For a word game in English, I would just copy Scrabble's frequency. Make a 100-or-whatever vector of the letters, compact as they're taken, rand across the current length.

Doc Block
Apr 15, 2003
Fun Shoe
Yeah, that's basically what I'm doing. Was curious if there was a better way, but this is good enough. Thanks. Good call on using Scrabble's frequency though, it's a better fit for word games.

Doc Block fucked around with this message at 04:04 on Mar 16, 2015

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Doc Block posted:

Another question: is there a better way to determine if a word entered by the player is an actual English word than by just throwing a huge list of all English words as separate strings into an NSSet (or NSDictionary) and then calling -member:?

NSSet will be slow to initialize with tens of thousands of strings, but maybe that isn't a concern for you. If it is, you can stick your words in a static array and binary search it (bsearch_b is a cool function). That's surely fast enough for your needs unless you're writing some kind of a solver.

Something like a trie will get you faster lookups, and if you're smart about how you package it you can keep the initialization time down too. (I think OmniFoundation has a trie implementation if you would like one off the shelf.)

From the dumb-idea-that-I-know-actually-works-because-I-did-it-once department, you can get Ragel to compile you a hilariously fast state machine for validating words with instantaneous initialization. Gotta ulimit up the stack size for the Ragel compiler though, a machine consisting entirely of sixty-thousand unions doesn't go down easy.

Doctor w-rw-rw-
Jun 24, 2008

Doc Block posted:

Another question: is there a better way to determine if a word entered by the player is an actual English word than by just throwing a huge list of all English words as separate strings into an NSSet (or NSDictionary) and then calling -member:?

Build a trie, or precompile a DFA like pokeyman says.

Doc Block
Apr 15, 2003
Fun Shoe

pokeyman posted:

NSSet will be slow to initialize with tens of thousands of strings, but maybe that isn't a concern for you. If it is, you can stick your words in a static array and binary search it (bsearch_b is a cool function). That's surely fast enough for your needs unless you're writing some kind of a solver.

Not to be contrarian, but it's actually pretty quick. Loading 80k words into an NSSet takes ~0.1 seconds on an iPhone 6, and on an iPhone 4 it only takes ~0.7 seconds. (On my Mac it takes effectively zero time ;)).

And once loaded, NSSet is plenty fast enough. I'm not writing a solver, I just need simple "Is what the user entered in the dictionary?" lookups.

pokeyman posted:

Something like a trie will get you faster lookups, and if you're smart about how you package it you can keep the initialization time down too. (I think OmniFoundation has a trie implementation if you would like one off the shelf.)

I'll look into this, thanks.

Doc Block fucked around with this message at 07:01 on Mar 16, 2015

Froist
Jun 6, 2004

Doc Block posted:

Not to be contrarian, but it's actually pretty quick. Loading 80k words into an NSSet takes ~0.1 seconds on an iPhone 6, and on an iPhone 4 it only takes ~0.7 seconds. (On my Mac it takes effectively zero time ;)).

And once loaded, NSSet is plenty fast enough. I'm not writing a solver, I just need simple "Is what the user entered in the dictionary?" lookups.

For a game I wrote, I had to do a brute force scan of the game grid on every turn to check whether there was a word starting at any tile (bad idea). I ended up getting good performance and memory usage by storing precomputed hashes of the whole word list in an NSSet and then using containsObject on this. I was also able to reduce the dictionary size a lot by only allowing 3-7 letter words, so I'd recommend something like that if it's at all applicable.

kode54
Nov 26, 2007

aka kuroshi
Fun Shoe
What in the gently caress? I am trying to run an ARM emulator on an iPod Touch 5th Gen, to run a music generator for a particular console format. The loader for the format produces a 64MB memory block, containing a Nintendo DS rom image, trimmed of most of its data, that does nothing but play music. Somehow, about 7168 samples into the song, it frees that ROM memory block in the middle of execution. I see no place in my code where it could be freeing that memory inside of the emulator, and unless the threading is totally wacky in this app I'm trying to insert this into, the outer process shouldn't have freed that memory, either.

EDIT: Disregard that, I suck cocks. Container class still had a copy of the ROM pointer, and it was freeing it when going out of scope.

kode54 fucked around with this message at 08:07 on Mar 17, 2015

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Doc Block posted:

Yeah, that's basically what I'm doing. Was curious if there was a better way, but this is good enough.

The way to do it from an arbitrary frequency table is just the floating-point generalization of the same idea. Build a table mapping letters to the cumulative frequency of all earlier letters, generate a random number from the uniform [0,1) distribution, and do a binary search to find the lower bound. That is, if A is 5%, B is 20%, C is 15%, D is 40%, and E is 20%, you build the table { 0, 0.05, 0.25, 0.4, 0.8 }; if the random number generator gives you .347634, the greatest lower bound of that is at index 2, so you generate 'A' + 2 == 'C'.

lord funk
Feb 16, 2004

I know, iTunes Connect, drag-and-drop screenshots is hard! It's okay. Take your time. Don't save. I've only got dozens of these to go.

edit:
We're temporarily unable to save your changes. Please try again later.
We're temporarily unable to save your changes. Please try again later.
We're temporarily unable to save your changes. Please try again later.
We're temporarily unable to save your changes. Please try again later.
We're temporarily unable to save your changes. Please try again later.

lord funk fucked around with this message at 18:31 on Mar 16, 2015

Inevitable Ross
Jul 1, 2007
Have you accepted Bob as your personal Lord and Savior?
It's never too late for https://fastlane.tools - deliver and snapshot are both pretty great, even on their own.

Doh004
Apr 22, 2007

Mmmmm Donuts...
Aight, who here knows UICollectionView animation and layouts like the back of their own hand? Here's what I got:

Standard collectionview with supplementary headers and footers, x amount of cells (only initially showing 2), and y amount of sections. Nothing crazy.

When a user taps on the footer, we want to make the header and footer sticky to the top and bottom respectively. We insert a bunch more rows into the section and want the user to be able to scroll through the entire section.

User taps again on the footer and the reverse happens, delete some rows, unsticky the header and footer and we're back to normal.

Where this gets tricky is that we could be doing this for any of the sections. We also don't want the user to be able to scroll through the other sections other than the one we're "editing".

My current line of thinking (which doesn't really work): Set a flag saying we're entering editing, invalidate the layout which tells the header and footer for the section to goto their respective locations, turn off animations and performBatchUpdates and deleteSection on the sections I'm not editing, insert into the 0 section (the one we're now editing as it's the only one in the data source).

I run into a bunch of flickering issues, content offsets getting hosed up all over the place and really weird zIndex issues.

What say you, much smarter and more experienced folks? Am I missing something super obvious here?

Kallikrates
Jul 7, 2002
Pro Lurker
have you tried doing everything you said while also manually tweaking UICollectionViewLayoutAttributes of the cells you are animating? They have a zIndex Property that is sometimes important to change. The problem with collectionView stuff is that the API Is so big. Even if its a bog standard flowlayout once you want to do animations that aren't built in you'll need to modify LayoutAttributes so that intermediate states during animations make sense.

There is also the possibility that instead of doing this via cell animations you doit via transitioning between an editing layout and a scrolling layout. More work will be done for you to handle animations, but you need to offset that by handling the transition between them.

lord funk
Feb 16, 2004

Doh004 posted:

What say you, much smarter and more experienced folks? Am I missing something super obvious here?
Have you tried moving into a cabin in the wilderness, living off the land, and never touching a computer again? I think I'd take that over working with UICollectionViews again. :v:

mrbass21
Feb 1, 2009
NSURLSession is amazing, but I'm having trouble with it.

I download files in chunks, where each chunk has a unique location on the server. I get a file that has all the locations, and go through a loop where I create data tasks for all the chunks and resume them. It works great for smaller files, but I'm getting to a problem with larger files.

I create a main session and add downloadDataTasks like so:

NSURLSessionDataTask newDownloadTask = [mySession dataTaskWithRequest:filledOutRequest completionHandler:^{ My handling code;}];
[newDownloadTask resume];

For a test file that is failing and is ~400 MB and has 65 chunks, around chunk 38, everything is fine, then 39-65 all immediately time-out. My setTimeoutForResource is set to default which is 7 days, and from the documentation, this controls how long a session task exists in the Session queue. So, I tried extending setTimeoutForRequest to 7 days and it worked. setTimeoutForRequest would be bad to keep at that value in case a server actually DID timeout.

I read that the TimeoutForRequest starts as soon as you call resume, leading me to my big question. Am I using resume wrong currently or do I need to create a chain where I launch HTTPMaximumConnectionsPerHost tasks with resume, and then call resume on the next task as a previous one completes? I was hoping that was completely handled by NSURLSession, and I could just throw tasks in there and forget about them.

Thanks.

mrbass21 fucked around with this message at 18:54 on Mar 17, 2015

Doh004
Apr 22, 2007

Mmmmm Donuts...

Kallikrates posted:

have you tried doing everything you said while also manually tweaking UICollectionViewLayoutAttributes of the cells you are animating? They have a zIndex Property that is sometimes important to change. The problem with collectionView stuff is that the API Is so big. Even if its a bog standard flowlayout once you want to do animations that aren't built in you'll need to modify LayoutAttributes so that intermediate states during animations make sense.

There is also the possibility that instead of doing this via cell animations you doit via transitioning between an editing layout and a scrolling layout. More work will be done for you to handle animations, but you need to offset that by handling the transition between them.

I'm not manually setting the zIndex of the cells as they're appearing, but I"ll try setting them manually.

And yeah, transitioning between layouts is definitely an option. The thing that I'm hung up the most about is going from n amount of sections to just 1, and not having it look like poo poo.

lord funk posted:

Have you tried moving into a cabin in the wilderness, living off the land, and never touching a computer again? I think I'd take that over working with UICollectionViews again. :v:

Yes :saddowns:

Kallikrates
Jul 7, 2002
Pro Lurker

Doh004 posted:

And yeah, transitioning between layouts is definitely an option. The thing that I'm hung up the most about is going from n amount of sections to just 1, and not having it look like poo poo.

There are some CollectionView(Layout?) delegate methods that allow you to setup Item Layout Attributes before and after transitions (Context will interpolate?). Maybe make the other cells transparent or CGSizeZero. Instead of trying to trick layout via the data source.
FlowLayout <-> EditingLayout(editingSection)

The whole stack can be hacked into. (Subclassing the layout attribute objects, modifying how attributes are applied to the cell, all the protocols).

Note, all that I've learned about CollectionViews I learned in trenches and after months of time, we came out the other side with a custom ScrollView.

Fate Accomplice
Nov 30, 2006




Ideas for good iOS interview questions?

I just asked this of an intern candidate:

Grandparent retains parent. Parent retains child. Child retains parent. Grandparent releases parent. What happens and why is it bad?

response? blank stare. This is someone with published apps in the store.

brap
Aug 23, 2004

Grimey Drawer
Strong reference cycle? I never call retain and release in my iOS programming, but having read about ARC I can recognize that.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Yeah, I could see how someone who had only learned after ARC was implemented would be tripped up. Maybe they would have understood it in terms of strong references.

Doh004
Apr 22, 2007

Mmmmm Donuts...

Malloreon posted:

Ideas for good iOS interview questions?

I just asked this of an intern candidate:

Grandparent retains parent. Parent retains child. Child retains parent. Grandparent releases parent. What happens and why is it bad?

response? blank stare. This is someone with published apps in the store.

Ask them what the different ways we handle concurrency are in iOS. Then when (if) they say GCD, NSOperations and NSThread ask them to explain the differences and when/why you'd want to use them.

Kallikrates
Jul 7, 2002
Pro Lurker
Ask them to explain the difference between int and NSInteger ( you can lead this into a discussion of various things)
depending on how badly they do ask about NSNumber (this line of questioning usually raises alot of red flag)

Unfortunately alot of people don't know about retain cycles, and tend to need a lot of handholding on it and lose time. It's a pretty teachable/learnable concept we ask it but its not a huge red flag if they can be walked through.

If they have pre-arc experience you can ask them to white board a simple getter/setter. (My team likes this I'm not super enthusiastic)

Usually we ask very general questions about UIkit/Appkit in phone screens to judge their rough experience level (What frameworks have you used, ever have any trouble with one, how'd you approach it etc). Going deeper into API, Language specific is very hit and miss, and we do a small 2hr homework problem in obj-c/swift to make sure they have a minimum level of xp. Many people don't have to go into the runtime, or custom UIView work, etc. That stuff is only a Google away.

This means that the in person is more about general programming practices, so simple fizzbuzz type questions. How they approach architecture. We might ask questions about the code they turned in for homework. If they have apps we ask questions about those, or github, or anything else we see on their resume.

Clear questions that don't take single word answers basically.

Kallikrates
Jul 7, 2002
Pro Lurker
Retain/release/cycles is something to keep in mind for long running blocks or blocks that are stored. ARC will not, cannot catch those.

mrbass21
Feb 1, 2009

Kallikrates posted:

Retain/release/cycles is something to keep in mind for long running blocks or blocks that are stored. ARC will not, cannot catch those.

Maybe ask about referencing self in a block if they know concurrency. Make sure they make/use a weak reference to self in a block.

Edit: Kallikrates: I wasn't calling you out. I just thought of that question while I read your post and quoted it more as a train of thought kind of thing. I think that would be a good way of evaluating retain cycles in someone who has only used ARC.

mrbass21 fucked around with this message at 21:08 on Mar 17, 2015

Kallikrates
Jul 7, 2002
Pro Lurker

mrbass21 posted:

Maybe ask about referencing self in a block if they know concurrency. Make sure they make/use a weak reference to self in a block.

It was more a response to the followup comments. I interpreted some comments as meaning that worrying about memory stuff is unimportant in ARC.

Also using blocks does not necessarily imply concurrency. There are plenty ways to run them in a serial manner.


One classic question. Is to explain why someone would use KVO/Notifications/Delegation/Block based API.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Sampled from our iOS interviewing guide, which I'm sure I won't get fired for posting:

quote:

What happens when you send a message to an object that doesn't implement the method? (see http://arigrant.com/blog/2013/12/13/a-selector-left-unhandled for different depths to which a candidate might answer)

What are KVO and KVC? lots of possible depth here, including higher-order messaging and the runtime subclassing used when observing an object.

Describe how you'd implement autorelease.

Doh004
Apr 22, 2007

Mmmmm Donuts...

Kallikrates posted:

There are some CollectionView(Layout?) delegate methods that allow you to setup Item Layout Attributes before and after transitions (Context will interpolate?). Maybe make the other cells transparent or CGSizeZero. Instead of trying to trick layout via the data source.
FlowLayout <-> EditingLayout(editingSection)

The whole stack can be hacked into. (Subclassing the layout attribute objects, modifying how attributes are applied to the cell, all the protocols).

Note, all that I've learned about CollectionViews I learned in trenches and after months of time, we came out the other side with a custom ScrollView.

I'd thought about setting their size to 0, but I feel like that'll still cause a whole lot of unnecessary scrolling?

And yeah, I've gone through and pretty much implemented every drat method for override of flow layout.

Kallikrates
Jul 7, 2002
Pro Lurker
At some points you have to let the Flowlayout go.....
You can also set the center/origin of layout attributes

Anything you can do with a view's frame you can do with a collection layout attribute (and more with transforms) with optional side effects of updating the containing collection view bounds.

Kallikrates fucked around with this message at 21:38 on Mar 17, 2015

Blakles
Mar 10, 2008

I have lived a great deal among grown-ups. I have seen them intimately, close at hand. And that hasnt much improved my opinion of them.
Continuing from my question a few posts back...

I now have the following setup:

Container View (houses menu that is used on all other view controllers) --> Navigation Controller --> View Controller 1 --> View Controller 2 --> (View Controller A [-->more view controllers...], View Controller B [-->more view controllers...], View Controller C [-->more view controllers...])

I need to be able to pop back to a specific view controller (for instance, back to VC2, VCA, VCB or VCC) based on which button is tapped in the menu (located in container view). Most of what I've tried has resulted in nothing happening or a crash with not very helpful error messages. Can anyone point me in the right direction to get this working? Here's is one thing I've tried:

code:
UINavigationController *myNavigationController = [UIApplication sharedApplication].keyWindow.rootViewController.navigationController;
UIViewController *homeViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Home"];
[myNavigationController popToViewController:homeViewController animated:YES];

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
You need a reference to the actual instance of the home view controller that's on the navigation stack. In that code sample, you're creating a brand new home view controller then asking the navigation controller to pop to it, but it's brand new so it never got pushed.

Since you're using storyboards, you might be able to take advantage of unwind segues to simplify things.

Blakles
Mar 10, 2008

I have lived a great deal among grown-ups. I have seen them intimately, close at hand. And that hasnt much improved my opinion of them.

pokeyman posted:

You need a reference to the actual instance of the home view controller that's on the navigation stack. In that code sample, you're creating a brand new home view controller then asking the navigation controller to pop to it, but it's brand new so it never got pushed.

Since you're using storyboards, you might be able to take advantage of unwind segues to simplify things.

How do I get a reference to the actual instance of the home view controller? The big issue seems to be that I'm trying to call a navigation controller method from outside the stack (the container view). I can copy and past the menu that's in the container view into every single view controller, but that seems insane and I can't imagine that's how other people are doing it. How can I get a method to run as the current view controller in the navigation stack instead of the container view that is triggering the method?

I looked into unwind segues but I run into the same issue. It won't go back through the navigation hierarchy because it's being called from the container view which is not in the navigation stack.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
A navigation controller can only pop back to a view controller that was, some time before, pushed. Is your intended destination a member of myNavigationController.viewControllers? If so, you can pull it out of there and pop to it:
Objective-C code:

UIViewController *homeViewController = myNavigationController.viewControllers[1];
[myNavigationController popToViewController:homeViewController animated:YES];
Does that make sense? And do you see why your earlier attempt must fail?

Blakles
Mar 10, 2008

I have lived a great deal among grown-ups. I have seen them intimately, close at hand. And that hasnt much improved my opinion of them.

pokeyman posted:

A navigation controller can only pop back to a view controller that was, some time before, pushed. Is your intended destination a member of myNavigationController.viewControllers? If so, you can pull it out of there and pop to it:
Objective-C code:
UIViewController *homeViewController = myNavigationController.viewControllers[1];
[myNavigationController popToViewController:homeViewController animated:YES];
Does that make sense? And do you see why your earlier attempt must fail?

Yes, that makes sense. The view controller that I'm trying to pop to (Home) has already been pushed at this point in the app. I tried your code, but it does nothing. When I try to log all the view controllers using the code below I get (null) even though I've pushed three or more view controllers from the navigation controller.

code:
UINavigationController *myNavigationController = [UIApplication sharedApplication].keyWindow.rootViewController.navigationController;
NSArray *stack = myNavigationController.viewControllers;
NSLog(@"%@",stack);
Edit: How can I communicate between my container view controller and the view controllers inside the navigation controller? (example: button is tapped in container view, then current view controller in navigation stack calls pop method)

Blakles fucked around with this message at 15:39 on Mar 18, 2015

Doh004
Apr 22, 2007

Mmmmm Donuts...
Sounds like you're not pushing to the correct navigationController. Print out the navigation controller you're pushing to in the debugger to get its memory address. Then when you're trying to find its viewController stack, print it out again and see if they're referencing the same location.

Blakles
Mar 10, 2008

I have lived a great deal among grown-ups. I have seen them intimately, close at hand. And that hasnt much improved my opinion of them.

Doh004 posted:

Sounds like you're not pushing to the correct navigationController. Print out the navigation controller you're pushing to in the debugger to get its memory address. Then when you're trying to find its viewController stack, print it out again and see if they're referencing the same location.

How can I get the correct navigation controller? I think my problem is most answers online are saying to use rootViewController like in my code above, but my navigation controller is not in the rootViewController. The rootViewController of my app is the container view.

Blakles fucked around with this message at 16:09 on Mar 18, 2015

Doh004
Apr 22, 2007

Mmmmm Donuts...

Blakles posted:

How can I get the correct navigation controller? I think my problem is most answers online are saying to use rootViewController like in my code above, but my navigation controller is not in the rootViewController. The rootViewController of my app is the container view.

Have you tried having references to your various navigationControllers in say either your container view controller or your app delegate? I've done this in the past:

In my app delegate
code:
@property (strong, nonatomic) MyContainerViewController containerViewController;
In my container view
code:
@property (strong, nonatomic) UINavigationController myNavigationController;
Set your app delegates window.rootViewController to your containerViewController. Then from wherever in your app you can do [UIApplication sharedApplication].delegate (and cast it as your app delegates class).

geera
May 20, 2003

Doh004 posted:

Set your app delegates window.rootViewController to your containerViewController. Then from wherever in your app you can do [UIApplication sharedApplication].delegate (and cast it as your app delegates class).
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.

Carthag Tuek
Oct 15, 2005

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



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/

Blakles
Mar 10, 2008

I have lived a great deal among grown-ups. I have seen them intimately, close at hand. And that hasnt much improved my opinion of them.
Is it possible to push a view controller after doing an unwind segue?

Right now I have a button that does an unwind to:

code:
- (IBAction)unwindToHomePushToViewB:(UIStoryboardSegue *)segue
{
    [self performSegueWithIdentifier:@"goToViewB" sender:self];
}
For some reason it does the "goToViewB" first, then back to the view controller where the "unwindToHomePushToViewB" function is. Why is it doing it in the wrong order? Is there any way to get it to do what I need?

EDIT: Got this to work by moving the performSegueWithIdentifier into viewDidAppear method.

Blakles fucked around with this message at 22:33 on Mar 18, 2015

Adbot
ADBOT LOVES YOU

Toady
Jan 12, 2009

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.

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

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