Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6100811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:25:42+00:00 2026-05-23T13:25:42+00:00

I think this is simple, but I am having big problem with this. I

  • 0

I think this is simple, but I am having big problem with this.

I have 2 UIViewController, one is the “Central” controller and other is for use the camera to decode a barcode.

In Central UIViewController, I call to run the barcode:

   barCode = [[MyBarCode alloc] init]
   [barCode openBarCodeReader];
   //[barCode release];  //can't release it here, this cause problem with camera
}  //function finish

The MyBarCode object will take control of the program. First it create a simple view to UIViewController

- (void) loadView {
    UIView *frame = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [frame setBackgroundColor:[UIColor clearColor]];
    self.view = frame;
}

Than start and configure the BarCode objects and start the camera with a

[self presentModalViewController:barCodeView animated:YES];  

Now, some time later, I have to dismiss this controller

[barCodeView dismissModalViewControllerAnimated:YES];

I send the data with a delegate function, and now this UIViewController finish their job and have to be released. I tried somethings:

  1. Send another delegate message. But, if I do [barCode release]; in this delegate, the program crash, because the barCode object is still running and need go to next instruction

  2. I can send a [self release] but i don’t know if it work and where the program will go in the “Central” UIViewController after it.

  3. I can dismiss this aux UIViewController with a

    [self dismissModalViewControllerAnimated:NO];
    

    But again, where the program go in the Central UIViewController.

Anyone have idea to solve this problem?

** Edit **

Maybe I found the answer:
I will not call the delegate like a method

[theDelegate BarCodeFinish];

But call it with a notification.

[[NSNotificationCenter defaultCenter] postNotificationName:@"BarCodeFinish" object:nil];

The fist case I still will run the next code after that call, but in the second, the call will run after it finish the function it is inside, and I can release the barcode object with no problem. Is this the best way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:25:43+00:00Added an answer on May 23, 2026 at 1:25 pm

    If i understand the second view controller which take control of your program is presented modaly and you looking for a way to dismiss the view controller and release the bar code ?

    In my opinion this should be done in a delegate method. For example :

    -(void)barCodeReader:(UIViewController *)aViewController didReadBarCode:(NSUInteger)theBarCode;
    

    Write that method in your first view controller, then set it as the delegate of the second.
    You can even better write your own protocol… But, once the second view controller has read the bar code call your custom method.
    A way to implement it should be :

    -(void)barCodeReader:(UIViewController *)aViewController
          didReadBarCode:(NSUInteger)theBarCode {
        // stop the bar code reader
        [barCode release];
        // dismiss the second view controller
        // do something with theBarCode
    }
    

    Once that method returns, your app will wait for the next event, probably some Internet provided data, after sending the code.

    I used NSUInteger as the argument but you can set a type of your own.
    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think this must be simple but I can't get it right... I have
I'm trying to get this simple PowerShell script working, but I think something is
this seems like very simple maths but somehow, my brain cant think ... i
This should be a really really simple thing, but for some reason it is
What is the function of the namespace here? I would think in this simple
I think this is specific to IE 6.0 but... In JavaScript I add a
I think this is pretty typical, you have the same website project with an
I think this will be easy but I can't see how to do it!
Here is a small problem I am having. 3 very simple models : >>>
This is likely something easy to accomplish, but I'm having difficulty even articulating clearly,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.