---
title: "What is messaging?"  
description: "What is messaging?"  
author: "Anonymous User"  
published: 2015-07-20  
updated: 2020-09-18  
canonical: https://www.mindstick.com/interview/2713/what-is-messaging  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 2 minutes  

---

# What is messaging?

Messaging is the terminology for invoking methods on an object. The format for a message expression is as follows (the brackets are required):

[object method]

or in Objective-C parlance

[receiver message]

**Simple example:**

```
// Create an instance of SomeClass object
SomeClass *ptr = [[SomeClass alloc] init];
// Send the message 'printInstanceVars' to the 'ptr' receiver
[ptr printInstanceVars];
```

If we want to pass an argument as part of the message (that is, pass a parameter to the method), we send a message that looks like this:

[receiver message:argument]

For example, assume setStr and setX are two methods in the SomeClass object and ptr is a pointer an instance of SomeClass . Here is how we might pass arguments to each method.

*[ptr setStr:@"Testing"];*

*[ptr setX:2008];*

**Side note:** The @ symbol at the front of @”Testing” string is convenience method that converts the given string to an NSString object, which in the case of the setStr method, is the required type for the parameter.

## Answers

### Answer by Anonymous User

Messaging is the terminology for invoking methods on an object. The format for a message expression is as follows (the brackets are required):

[object method]

or in Objective-C parlance

[receiver message]

**Simple example:**

```
// Create an instance of SomeClass object
SomeClass *ptr = [[SomeClass alloc] init];
// Send the message 'printInstanceVars' to the 'ptr' receiver
[ptr printInstanceVars];
```

If we want to pass an argument as part of the message (that is, pass a parameter to the method), we send a message that looks like this:

[receiver message:argument]

For example, assume setStr and setX are two methods in the SomeClass object and ptr is a pointer an instance of SomeClass . Here is how we might pass arguments to each method.

*[ptr setStr:@"Testing"];*

*[ptr setX:2008];*

**Side note:** The @ symbol at the front of @”Testing” string is convenience method that converts the given string to an NSString object, which in the case of the setStr method, is the required type for the parameter.


---

Original Source: https://www.mindstick.com/interview/2713/what-is-messaging

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
