Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

how to get object from a function in objective-C?

raptor85raptor85 Posts: 74Registered Users
I want to get object from this function i need to get "notif "..so that i can use that object in notificationChangedForSymptom function ..

- (void)scheduleNotification :(int)remedyID
{

[[UIApplication sharedApplication] cancelAllLocalNotifications];

Class cls = NSClassFromString(@UILocalNotification);
if (cls != nil) {

UILocalNotification *notif = [[cls alloc] init];



-(void)notificationChangedForSymptom:(int)symptomIDNo withRemedyID:(int)remedyID isSelected:(BOOL)isSelected
{
if (isSelected == YES)


//like this
[self scheduleNotification:remedyID scheduledNotification:notif];

can anyone help me ..
Thanks

Replies

  • baja_yubaja_yu San FranciscoPosts: 6,215Moderators, Registered Users Admin
    Your code is all over the place. Also, you should use code tags when posting code here, it makes it much easier to read.

    1. Why don't you change the scheduleNotification to return a notification instead of void?
    2. Your scheduleNotification takes one parameter (remedyID), yet you're calling it like it has two.
    3. Are you supporting iOS 3.x or lower? Because if you're not, there's no reason to use NSClassFromString, since UILocalNotification is available in iOS 4 and above. In fact, even if you do, that by it self is still not enough, since cancelAllLocalNotifications too is available from iOS 4 and above, so that call would crash on iOS 3.x and lower.
  • raptor85raptor85 Posts: 74Registered Users
    edited January 2013
    so my - (void)scheduleNotification :(int)remedyID changed to

    -(uilocalnotification *)scheduleNotification :(int)remedyID setNotfication:(uilocalnotification *)notify ?
    {
    //code

    return notify;
    }

    2)since I m returning notif in earlier function ..can I call the function as [self schedule notification:remedyID set notification:notify] in
    -(void)notificationChanged method

    3) i am supporting ios5> ..
    if i am wrong what should be functionname
    shall i mail my project .. so that u will get clear idea of what i am trying to do

    before the time is set .in my app icon .a notification comes up with a number 1 in red color ..notification is firing at right time though
    any idea why its happening
    Post edited by raptor85 on
Sign In or Register to comment.