Mac Forums

Mac Forums (http://www.mac-forums.com/forums/)
-   OS X - Development and Darwin (http://www.mac-forums.com/forums/os-x-development-darwin/)
-   -   need help from a programmer (http://www.mac-forums.com/forums/os-x-development-darwin/301298-need-help-programmer.html)

Yodda_Hunter 07-20-2013 04:34 PM

need help from a programmer
 
how do i write Vbcrlf (It's from visual basic) at coaca?

vbcrlf put texts under each other

Raz0rEdge 07-20-2013 08:33 PM

For logging using "NSLog", the newline, carriage return is added for you automatically..

The vbCrLf command basically adds a Carriage Return, and Line Feed..

What are you trying to do?

Yodda_Hunter 07-21-2013 05:47 AM

i want to write"Hey" then press button then it shows,then write "What's up?" and press button,then i get this
----------
hey
what's up?
----------

Raz0rEdge 07-21-2013 07:03 AM

So you are trying to do a command line program in Cocoa?

Yodda_Hunter 07-21-2013 10:26 AM

i don't know what do you mean but if you know something about visual basic tell me what does VBCRLF equal in cocoa

vansmith 07-21-2013 12:32 PM

A carriage return is accomplished by using \r and a line break is \n.

Yodda_Hunter 07-21-2013 03:34 PM

okay i tried to write "\n" but it gave me choices on of them was Nsstring/Nstring. so it's not purely \n xD.could you write an exist code for me?

vansmith 07-21-2013 04:32 PM

You put \r and \n within the confines of your string. So, a string might look like the following:
Code:

NSString *myString = @"My String\n";
That would produce:
Code:

My String
<new line>


Yodda_Hunter 07-21-2013 04:51 PM

Quote:

Originally Posted by vansmith (Post 1527493)
You put \r and \n within the confines of your string. So, a string might look like the following:
Code:

NSString *myString = @"My String\n";
That would produce:
Code:

My String
<new line>


thanks a lot. you helped me a lot. you are the first guy who gave me the right answer for my questions xD

Yodda_Hunter 07-21-2013 05:21 PM

well,rigth now i'm stuck xD . i want to connect to commands with each other :S
i want to say ( X + _"Something" .stringvalue; so how is it?

vansmith 07-21-2013 06:41 PM

Can you reword that? I'm not sure I understand what you're trying to do.

Raz0rEdge 07-21-2013 08:31 PM

To concatenate two strings, you have a couple of options. One is to use to use a NSMutableString, and the other is to string with the NSString, but create a new one..

So for example..
Code:

NSString *first = @"Hello ";
NSString *second = @"World";

NSString *result = @"";
result = [result stringByAppendingString:first];
result = [result stringByAppendingString:second];

The NSString result now contains "Hello World" in it..

The second option is
Code:

NSString *second = @"World";
NSMutableString *result = @"Hello ";

result = [result appendString:first];

The NSMutableString result now contains "Hello World".

You might want to read up on Mutable and Immutable objects and see the pros and cons about using one over the other..

Yodda_Hunter 08-05-2013 05:18 PM

Quote:

Originally Posted by vansmith (Post 1527493)
You put \r and \n within the confines of your string. So, a string might look like the following:
Code:

NSString *myString = @"My String\n";
That would produce:
Code:

My String
<new line>


that's what i wanted but no exactly, i wanna variable instead of constants


All times are GMT -4. The time now is 10:33 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.