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 8630749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:07:09+00:00 2026-06-12T09:07:09+00:00

I know what a function is, but I am trying to write a few

  • 0

I know what a function is, but I am trying to write a few into my project. I have just watched a video series on Objective-C from Lynda.com where I got the idea from.

In the video is it is explained that I can write a function like this:

void declareWebView ()

However if I write it like that into my code, the error comes up and says that my _webView and self (as self.view) are not available.

if I write it like this:

-(void) declareWebView

Then I do not have an issue.

Any ideas on how to get the first one right?
As far as I can tell, I cannot set any parameters with the second way of writing.

  • 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-06-12T09:07:09+00:00Added an answer on June 12, 2026 at 9:07 am

    The first is as you said called a function. It is part of the C part of Objective-C, and is not connected to objects or classes, so the variable self or any instance variables of an object don’t have any meaning. You can pass it variables that are objects though like so:

    void my_func(NSString *string, id someObject, int someInt);
    
    void my_func(NSString *string, id someObject, int someInt)
    {
        NSLog(@"string = %@, someObject = %@, someInt = %d",string,someObject,someInt);
    }
    

    The second is a method, and in a method you can access self and, within instance methods, access instance variables. Replacing the “-” in front of the method with a “+” makes it a class method. In a class method you can’t access instance variables and self refers to the class itself, not an instance.

    Hope this helps!

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

Sidebar

Related Questions

I am trying to write a generic convert function but I don't know how
I know it's been done before but I'm trying to write this from scratch
I know JFile and write function in Joomla 1.6 but is there a similar
Pretty basic programming question, I know PHP have a function for it, but does
Hey all, I'm trying to write a sort function but am having trouble figuring
I am trying to write a function to copy words from source memory to
im trying to write a function that will sanitize data coming from the client
I am trying to write a static function to Or two expressions, but recieve
I'm trying to write a function in PL/PgSQL that have to work with a
Am trying to write a recurssive function to do something, but at each step

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.