We got the Vidyo SDK working great opening the first time. Everything works great, much based on the SDK code example. When call is done and the view is change we use viewDidDisappear and set:
[[NSNotificationCenter defaultCenter] removeObserver:self];
[vc disconnect];
[vc disable]; // releases the camera, mic, speaker
vc = nil;
[VCConnectorPkg uninitialize];
How every if we the start a new call we get EXC_BAD_ACCESS when calling the view.
Using Zombie in xcode gives me the following error:
*** -[LmiVideoCapturerImplementationAVFoundation retain]: message sent to deallocated instance 0x131f7f940
It feels like there is something we are not terminating correct, what are we missing?
The cause of that is you're trying to start a new call after [VCConnectorPkg uninitialize] was called.
Vidyo.io API calls should be smth like:
Call [VCConnectorPkg vcInitialize] only once - in
(void)viewDidLoad
Call [VCConnectorPkg uninitialize] only once - in
(void)appWillTerminate
Call [vc disable] and vc = nil in case if you leave the
Vidyo view controller.
And be sure you call vc = [VCConnector alloc] init:(void*)&videoView in case if you disabled and nil'ed it previously.
Related
I write iOS app and use imageStore library to lazy load images and cache them in memory. (https://github.com/psychs/imagestore)
On ViewController I create imagestore instance:
imageStore = [ImageStore new];
imageStore.delegate = self;
When image loaded successfuly, imagestore call delegate method
- (void)imageStoreDidGetNewImage:(ImageStore*)sender url:(NSString*)url
that doing reloadData on tableview to redraw cells.
All works good. But there is the problem: if ViewController didUnload (go back in navigation controller) and image loaded, application finish with crash, because imagestore call method of unloaded ViewController.
I try to do following:
1) in ViewController I place this code in viewDidUnload section:
imageStore.delegate = nil;
imageStore = nil;
2) In imageStore I added checking for nil:
if(delegate != nil) {
...call delegate method
}
It works, but periodically app crash anyway.
Try putting this code on dealloc section.
imageStore.delegate = nil;
imageStore = nil;
In the same way the if clause is not necessary because any call to an nil object is ignored by the application, so if you have something like this:
id delegate = nil;
[delegate callAnyMethod];
has no effect in your application behavior, in other hand if the call of the method delegate is optional you should asure that delegate responds to selector, something like this should do the trick:
if([delegate conformsToProtocol:#protocol(yourProtocolName)] && [delegate respondsToSelector:#selector(imageStoreDidGetNewImage:url:)]) {
[delegate imageStoreDidGetNewImage:imageStore url:url];
}
Cheers!
It works, but periodically app crash anyway.
That's a contradiction. There are two possibilities:
Your fix worked, and the app is crashing for some other reason.
Your fix did not work, the app continues to crash for the same reason it was crashing before.
It's hard to know what's wrong without knowing which of these two possibilities is in fact happening. Look at the error message and the evidence from the crash, such as the stack crawl. Why is the app crashing? Does it try to dereference the delegate property somewhere without checking it first? Does it depend on the delegate doing something, so that if the delegate no longer exists that thing doesn't get done and that in turn leads to a crash? These are the kinds of things I'd look for, but again the most important thing is to start with the evidence you have and follow your nose.
Being still new to iPhone development, I am slowly getting there however sometimes the simple things seem to stump me.
My application consists of 7 very different views. It is implemented as a window based app without a navigation controller. Navigation is managed by each view controller individually and I use a central data repository to make data available through the app.
I use :-
DetailView *viewDetail = [[DetailView alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:viewDetail animated:YES];
to change views. Obviously, in all cases, this is executed within the controller of the current view.
HOWEVER, I have now added Push Notification to the app. Upon receipt of a Push, the userInfo data is made available within the main AppDelegate and didReceiveRemoteNotification is executed. I wish to force the application into the Detailview described above, passing it one of the values within userInfo.
Of course, I get a nice SIGABRT as soon as it executes the second line. I assume this is because the currently active view is not self. How do I surrender the current view in favour of the DetailView from within the app delegate? The current view could be ANY of the 7 views, including DetailView, which I wil want to refresh with the new data.
Thanks in advance
Chris Hardaker
This is a small side note, but the naming convention that you are using is non-standard. Rather than,
DetailView *viewDetail = [[DetailView alloc] initWithNibName:nil bundle:nil];
conventionally, an iOS developer would expect to see the following:
DetailViewController *viewDetail = [[DetailViewController alloc] initWithNibName:nil bundle:nil];
since viewDetail is a subclass of UIViewController rather than UIView.
To answer you main question though, I would use NSNotificationCenter. Basically, this allows any class to post a notification, which more or less just throws out the fact that an event occurred to any class that happens to be listening for it.
So in didReceiveRemoveNotification: you can call:
[[NSNotificationCenter defaultCenter] postNotificationName:#"pushNotification" object:nil userInfo:userInfo];
When you allocate your view controllers, run this line:
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(pushNotificationReceived:) name:#"pushNotification" object:nil];
You will need to put a method called pushNotificationReceived: (NSNotification*)aNotification in each of the view controllers to handle the notification. The userInfo dictionary that you passed will be a property of the notification.
Now, when ever the #"pushNotification" notification is sent, your controllers will receive a notification and run the given selector. So you can dismiss the controller or show the detail view or whatever you want.
When you dealloc your view controller, make sure to call
[[NSNotificationCenter defaultCenter] removeObserver:self];
I am having a crash (triggered by an exception) while adding a WebView. I haven't figured out why. And yes I have browsed the web because this is a very common problem though with no success, I found an answer saying that I should implement the DSYM to track the stack correctly, because looking at all those addresses is just meaningless (and I agree), the thing is I have no idea on how to do this. I found this: save dsym files. But I didn't figure out how to integrate it into my project, besides it looks dangerous. And yes I have NSZombie enabled too, but to no avail.
Anyway now to the point of my question. I have a button that triggers an event, the event changes a string (the URL) according to the button pressed. Then this IBAction calls on the delegate, and the delegate makes a transition to a view that has a UIWebView that will open with the URL edited by the IBAction. So I have the following code:
This is the Delegate method:
WebViewController *awebViewController = [[WebViewController alloc]
initWithNibName:#"WebView" bundle:nil];
[self setWebViewController:awebViewController];
[awebViewController release];
self.webViewController.finalURL = [NSMutableString stringWithFormat:#"%#", linkString];
[viewController.view removeFromSuperview];
// HERE happens the crash, found out using breakpoints
[self.window addSubview:[webViewController view]];
[UIView commitAnimations];
[viewController release];
viewController = nil;
This is the exact crash message:
-[WebView initWithCoder:]: unrecognized selector sent to instance 0x5718320
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '[WebView initWithCoder:]: unrecognized selector sent to instance 0x5718320'
I have the theory that it tries to make the transition but that there is no actual view to add. Though that is a wild guess. Exceptions are usually called by those kinds of things but in this case I don't see what is happening.
Thank you for your help, and forgive me if it is too dumb a question.
a guess from my side:
Do you have a view in your nib that should be a UIWebView but you changed the Class of that view to WebView?
You should first check this in interface builder.
This exception is exactly what happens if you change the Class of a view element to a class that isn't available.
The exact error is that some instance of a class called WebView (not UIWebView) at memory address 0x5718320 is being sent the message -initWithCoder:, which it doesn’t recognize. That message is called when loading views created with Interface Builder; check your nibs for a view that you’ve changed to a custom WebView class.
I had same problem, and renamed class WebView into WebViewCustom by XCode refractor/Rename feature, cleaned up project and now it works fine.
I have an app that navigates thru different views using the navigation controller. This is what I’m doing:
MapViewController *aMap = [[MapViewController alloc] initWithNibName:#"MapView"
bundle:nil ];
[self.navigationController pushViewController:aMap
animated:YES];
[aMap release];
At an user action, I want to go back to the first view. This is what I did:
-(void)alertView:(UIAlertView *)alertView
didDismissWithButtonIndex:(NSInteger)buttonIndex
{
[self.navigationController popToRootViewControllerAnimated:NO];
}
When I press a button that call the bellow method, my app goes as expected to the first view. But the problem arises when I press the “Home button” and try to reopen the app. Then, the app crash giving the following error:
2010-12-23 14:33:18.504 test[4549:307] *** -[MapViewController respondsToSelector:]: message sent to deallocated instance 0x5c26320
I understand that I sending a message to an instance of the object that does not exist, but I don’t find where is this happening
Do you have any recommendation?
Something is trying to send messages to the MapViewController after it's been deallocated.
Are they any objects that reference it - is it the delegate for any of its subviews, or does it receive any notifications, or anything like that?
If so, you need to make sure you unsubscribe from any notifications in the controller's dealloc method, and set any delegate parameters (on other objects) that reference the controller to nil.
I must be getting a memory leak, I'm calling a graph library view and the view shows the first time I use this button method, but the second time the app crashes, with no real error message, that I can see.
-(IBAction)graphNavButtonPressed
{
UIViewController *vc = [[GraphController alloc] init];
[vc setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentModalViewController:vc animated:YES]; // APP FAILS ON THIS LINE
[vc release];
return;
}
Program received signal: “EXC_BAD_ACCESS”.
(gdb) bt
#0 0x02889903 in objc_msgSend ()
#1 0x0279a1c0 in __useVolatileDomainsForUser ()
#2 0x0267120c in CFPreferencesCopyAppValue ()
EDIT:
In GraphController ViewDidLoad I've got this code.
NSUserDefaults *myDefaults = [NSUserDefaults standardUserDefaults];
strCurrencySymbol = [myDefaults objectForKey:kNSUCurrency]; //HERE where it crashes
EDIT 2:
Ive been reading about someone with a similar problem, caused by a view being loaded incorrectly. link text I am doing something perhaps a little odd. In order to use the graph library from a tab bar, I load my date range view and then show the graph in viewDidLoad, then once the graph is closed the date range view remains. The user can then click view graph again to show the graph with different dates. If I don`t do this my view will be blank when the graph is closed. So heres how Im calling the graph.
I`m reusing the date range screen elsewhere so the graph may not be shown.
Any further suggestions ?
I guess you should not release the vc object in the same IBAction, because you are probably using it after arent you? not sure
The code you've posted is correct in terms of memory management. If you're having problems on presentation of the VC (or on its release) check memory management in the init, viewDidLoad, and dealloc of the GraphController. The problem's most likely in there somewhere.
Also, that stack trace looks like something in the graphing library is trying to acccess user preferences and failing, so I'd check GraphController for calls to CFPreferencesCopyAppValue and make sure it's being called properly.