AudioStreamer appDelegate - iphone

I have two things concerning AudioStreamer and i hope I'm getting some clues here:
1. I have set up a UITabBarController and in my Appdelegate is a AudioStreamer-Object. Two views refer to the appDelegate.streamer. It it looks like that im getting two sessions when i release and alloc it new. I get two running audiosession.
2. I use a UITableView to play out of this list. in the didSelectRowAtIndexPath-method I initialize with a URL. when the user taps with a fast double, or tripple-click. the audiosession will get startet three times. although i'm using a bool to prevent that. so my dirty solution is to set the system sleeping for a second. it is ugly because the screen freezes for a sec.
Thankfull for some hints
Simon

In terms of your problems, it sounds like you should implement your AudioSteamer as a singleton, as this will prevent multiple instances from being created and provide a single point to control playback (i.e.: prevent multiple taps from triggering multiple playbacks).
For more information on how to create a singleton class, see the "Creating a Singleton Instance" section within Apple's Cocoa Fundamentals Guide.

for 2nd point. It is a bug of AudioStreamer class. Also this has been solved and code is put up on gitHub see link. also if this does not seems working then you can go to the pause method and add more states as below
-(void)pause
{
if (state==AS_PLAYING || state==AS_BUFFERING || state==AS_WAITING_FOR_DATA)
{
//rest code goes same....
}
// rest code goes same....
}
this solved my same problem. Hope this will help you also...

Related

In-app tutorial

Im looking at adding a tutorial kind of thing to my app. Basically I want to be able to give a quick message across of what the parts in the app do. I want the users to see it once and not again. I have searched relentlessly for this but I always found app building tutorials.
A lot of games have what I want but I cannot for the life of me find how to do it or, what it is called to find a tutorial. Could someone please help me out.
Thanks in advance,
Sam
You'll need to build it yourself.
What I usually do is, on top of the view i want to explain, add a semi transparent view with some arrows pointing at stuff and a small text/button explaining it. All of that has to be modal and you can save in the NSUserDefaults if the user has already seen it/skipped it/launched the app for the first time. You'd have a method that builds all those views and you simply call it in viewDidLoad (by checking against a simple boolean value store in those previously mentioned NSUserDefaults, for example)

UIActivityViewController freeze in first time

When I call the first time UIActivityViewController, the interaction is locked. After the first click it will be normal without locking interaction, does anyone know how to not catch the first time?
Maybe this can help. I had a similar issue, UIActivityViewController was pretty slow to appear the first time.
I solved it removing AirDrop from the supported activity types (through excludedActivityTypes) and it became super fast.
So if you are not interested in AirDrop (my case) you can do something like this:
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
activityVC.excludedActivityTypes = #[UIActivityTypeAirDrop];
}
Note that UIActivityTypeAirDrop is only available starting from iOS 7.0.
I don't really understand the problem - you alloc/init a UIActivityViewController and then you present it with presentViewController:animated:completion, correct? Make sure to call the presentViewController... on the main thread. Sometimes UI stuff called on the wrong thread takes seconds to get executed. But it might also just be iOS - UIActivityViewController takes some time to check for available services and stuff, that might be the thing that's slowing it down too.

How mvc pattern is implemented in iOS user interface? (view-based XCode temlpate)

I'm new to iphone development. There's a lot of books on this topic available. But most of the beginner's guides are mostly concerned with Interface Builder usage and lack the information about existing built in XCode code templates or something that could help me in understanding MVC implementation in code. I found that it is possible to write working iOS program without ViewController at all. Well, it seems to me like that after working with the sample code called ViewTransitions.
So, the question is - why is that possible to avoid ViewController implementation in a program that has an interface with a button? If the answer is going to be too long, could you please recommend kind of tutorial or manual covering this topic.
Thanks in advance.
#user697562's answer is essentially correct: in the case of ViewTransitions, the role of the controller is played by the app delegate. The app does next to nothing -- it just switches betweeen two views to demonstrate several possible transition effects -- so a UIViewController isn't really needed there.
Notice that there's also nothing in ViewTransitions that you could really call a model object. If you're looking for a strong example of MVC, ViewTransitions isn't the best project to look at. Other sample projects, such as TheElements, give a better demonstration of MVC in action.
There is a concept called delegation. A concept which helps maintain MVC. It helps to keep the model separate from controllers. For eg: - UITableView/UICollectionView , which knows how to display the data and other ui stuff.
But it does not know which cell to display or what data to display at a particular index. And this is where delegation and the delegate object comes into place. UICollectionView handles all the view part whereas all the non view part is handled by the delgate object, which gives the required data for the view. This way a delegate(usually a separate view controller) acts as a data source and UICollectionView as a ui renderer.
in ViewTransitions, there IS an App Delegate, which is kind of your sole "controller". Even ViewTransitions has:
transition.delegate = self;
IOS is a bit different from some frameworks in that you aren't as "in control" of what is going on. It often uses a delegation model where you set your code as the delegate, but it (IOS) is in control. Still, you can write in MVC style, it's just your "C" isn't fully in charge.

Adding a lot of data to core data while keeping the UI responsive

I'm looking for a way to add a whole load of data to core data while keeping the little activity indicator spinning on the UI. I tried adding the data on another thread but since learned that core data is not thread safe, and I get all kinds of errors. Can anyone suggest another approach to this?
Thanks in advance.
Core Data is not thread-safe, but that just means you have to code appropriately, rather avoiding them entirely. To keep your UI responsive/up-to-date, you'll need to use threads.
Apple's documentation on the subject is here, and this blog post is an excellent walk-through of using multiple threads with Core Data, and some of the pitfalls involved.
You need to use a separate managed object context for each thread. There's some additional work you need to do to make changes from other contexts available to your main thread's context: see Concurrency with Core Data for a full discussion.
Most useful example is a core data XML downloading from iOS sample code. If u don't have access, please let me know and I will write here is a main structure of it.
There is a complex custom delegate techniques from u UIviewController to nsoperation delegate, this is important for u to start showing content immediately to user and show a progress of sync.
In AppStore u can see my "snow IXC" app, where u can see this techniques implemented for indicate user in their UIviewController about progress. It's free for downloading.
This is how I avoid background threads with a loading indicator (I use DSActivityView but this should work with other implementations):
In your code when you are going to be displaying the indicator run all the code to show the indicator first. After that code have a separate method call to do all the loading work. Call it by using the method:
[self performSelector:#selector(loadMethodName) withObject:nil afterDelay:0.0];
Normally the app will go straight into the loading code without waiting to show the indicator view. By calling it this way it will first finish displaying the indicator before it moves into the loading code.

Should I be fetching my Core Data more often?

So right now when my app starts I get all of my data from Core Data. My data has entities of Groups and People. The Groups contain People. So as I go through the app I'm adding and deleting People and Groups.
My problem lies when I select a Group from a tableview and I pass that Group onto the next tableview. From that tableview I can press a button/row and add a bunch of People from a modal view. When I press Done from that modal view I need it to update the previous view with those new People, which it's not doing correctly.
It seems a little, for lack of a better word, wrong that I'm passing a lot of stuff around. Would it be better for me to use another fetch after I update People in a Group? From reading what other people say, then I could have different views listen for an updated Core Data and change their views accordingly.
I really hope this makes sense. I've been reading a lot to try to figure out the best approach but I'm not getting anything definite. I feel like my code is turning into spaghetti so I stopped and I'm trying to rethink it all. I'm also thinking maybe I need my very own Model class as opposed to just the classes that Core Data auto-generates.
From what you've written what you're doing sounds about right. I assume you're using a NSFetchedResultsController. Have you implemented the delegate methods outlined in the docs? Specifically, the controllerWillChangeContent: method should give you what you're after.
Regarding implementing your own NSManagedObject subclass, take a look at MOGenerator.
I would recommend NSFetchedResultsController to you. See documentation at ...
http://developer.apple.com/library/ios/#documentation/CoreData/Reference/NSFetchedResultsController_Class/Reference/Reference.html
Look at CoreDataBooks example, especially at RootViewController.m at ...
http://developer.apple.com/library/ios/#samplecode/CoreDataBooks/Listings/Classes_RootViewController_m.html%23//apple_ref/doc/uid/DTS40008405-Classes_RootViewController_m-DontLinkElementID_14
NSFetchedResultsControllerDelegate can help you to update your previous view easily. As I wrote, look at sample code to see how it really works.