iOS Question Inline OBJC - Self

Discussion in 'iOS Questions' started by narek adonts, Apr 3, 2015.

  1. narek adonts

    narek adonts Well-Known Member Licensed User

    Hi,

    How can I use this code for exemple for Page1.

    Code:
    -(void)mediaPickerDidCancel:(MPMediaPickerController *)mediaPicker {
        [self dismissModalViewControllerAnimated: YES];
    }
    how can I point self to my Page1 for exemple

    Narek
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You need to pass Page1 as a parameter to the method (it is a UIViewController*).
     
  3. narek adonts

    narek adonts Well-Known Member Licensed User

    I tried. the first void is ok. but for the next 2 voids I can not pass page as parameter.
    Please see code
    Code:
    -(void) MMShow: (UIViewController*)mypage
    {
    MPMediaPickerController *mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeAny];
    mediaPicker.delegate = self;
    mediaPicker.prompt = @
    "Select Audio";
    [mypage presentModalViewController:mediaPicker animated:YES];
    }

    -(void) mediaPicker:(MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection {
        NSArray *selectedSong = [mediaItemCollection items];
        if ([selectedSong count] > 0) {
            MPMediaItem *songItem = [selectedSong objectAtIndex:0];
            NSURL *songURL = [songItem valueForProperty:MPMediaItemPropertyAssetURL];
            //audioAsset = [AVAsset assetWithURL:songURL];
             NSLog(@"Audio Loaded");
           
            
        }
        [self dismissModalViewControllerAnimated:YES];
    }
    -(void)mediaPickerDidCancel:(MPMediaPickerController *)mediaPicker {
        [self dismissModalViewControllerAnimated: YES];
    }
     
  4. narek adonts

    narek adonts Well-Known Member Licensed User

    or how can I assign a global property for my page1 to be able to use in all voids

    Narek
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    If Page1 is a global variable then you can access it with self._page1.
     
  6. narek adonts

    narek adonts Well-Known Member Licensed User

    it doest work

    error

    error: no visible @interface for 'B4IPage' declares the selector 'dismissModalViewControllerAnimated:'

    I used

    [self._page1 dismissModalViewControllerAnimated: YES];
     
  7. narek adonts

    narek adonts Well-Known Member Licensed User

    self._page1 return a B4IPage not UiViewController
     
  8. narek adonts

    narek adonts Well-Known Member Licensed User

    I finally managed to find the solution inside the .m file that b4i is compiling
    page1=(self._page1).object
     
    JordiCP and Erel like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice