Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-16-2011, 07:51 AM   #1 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 12
HalfFull is on a distinguished road
Default How to send strings using NSNotifcationCenter

Hi,

I am familiar with the basics of NSNotifcationCenter. I am able to get one view to 'talk' to another view (see below how I'm doing that currently). But I'd really like to send a string from one view to another using NSNotificationCenter. Here's what I have so far:

In the MainViewController.m I have an IBAction:

Code:
- (IBAction) receiveInformation{
     NSLog(@"I have received!");
}
which gets called in the viewDidLoad using this:

Code:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveInformation) name:@"pass" object:nil];
In my secondViewController.m I am using this to post the notification:

Code:
[[NSNotificationCenter defaultCenter] postNotificationName:@"pass" object:nil];


So my question is, how can I use NSNotificationCenter to send a string?

Thanks for any help.
HalfFull is offline   Reply With Quote
Old 06-16-2011, 08:09 AM   #2 (permalink)
Token farm animal
 
sneaky's Avatar
 
Join Date: Apr 2011
Posts: 321
sneaky is on a distinguished road
Default

Put your string into the 'object'

here's a good code example Example of communicating between parts of a Cocoa program using NSNotification notifications using Xcode and Interface Builder
sneaky is offline   Reply With Quote
Old 06-16-2011, 08:59 AM   #3 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 12
HalfFull is on a distinguished road
Default

Brilliant. That worked, thank you so much
HalfFull is offline   Reply With Quote
Reply

Bookmarks

Tags
nsnotificationcenter, string

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 320
6 members and 314 guests
chemistry, Dnnake, iOS.Lover, lendo, Leslie80, pbart
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,664
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Leslie80
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:24 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0