typedef结构指针问题

时间:2015-12-29 12:20:15

标签: c typedef

解决方案:超时提供所有参与者的回叫功能需求。 PRINT_OUT代码在其他地方工作。这是我内心的错误!!!

我已声明以下类型/结构:

      -(void)viewDidAppear:(BOOL)animated
        {
                NSURL * myUrl = [NSURL URLWithString:[arrVideoLink objectAtIndex:0]];
                moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:myUrl];
                moviePlayer.controlStyle=MPMovieControlStyleNone;

                [vwVideoview addSubview:moviePlayer.view];
                moviePlayer.view.frame =  CGRectMake(0, 0, vwVideoview.frame.size.width, vwVideoview.frame.size.height);           
                moviePlayer.view.layer.zPosition = 1;
                [moviePlayer prepareToPlay];

                [moviePlayer play];
                [[NSNotificationCenter defaultCenter] removeObserver:self
                                                                name:MPMoviePlayerPlaybackDidFinishNotification
                                                              object:moviePlayer];
                [[NSNotificationCenter defaultCenter] addObserver:self
                                                         selector:@selector(aMoviePlaybackComplete:)
                                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                                           object:moviePlayer];
                [[NSNotificationCenter defaultCenter] addObserver:self
                                                         selector:@selector(loadStateChanged:)
                                                             name:MPMoviePlayerPlaybackStateDidChangeNotification
                                                           object:moviePlayer];

                [[NSNotificationCenter defaultCenter] addObserver:self
                                                         selector:@selector(nowPlayingMovie:)
                                                             name:MPMoviePlayerNowPlayingMovieDidChangeNotification
                                                           object:moviePlayer];

                [[NSNotificationCenter defaultCenter] addObserver:self
                                                         selector:@selector(doneButtonClick:)
                                                             name:MPMoviePlayerWillExitFullscreenNotification
                                                           object:moviePlayer];
        }

     - (void)aMoviePlaybackComplete:(NSNotification*)notification
       {
                        if (urlIndex+1<=arrVideoLink.count-1)
                        {
                            NSURL * myUrl = [NSURL URLWithString:[arrVideoLink objectAtIndex:urlIndex+1]];
                            moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:myUrl];
                            moviePlayer.controlStyle = MPMovieControlStyleNone;
                            [vwVideoview addSubview:moviePlayer.view];
                            moviePlayer.view.frame = CGRectMake(0, 0, vwVideoview.frame.size.width, vwVideoview.frame.size.height);            
                            moviePlayer.view.layer.zPosition = 1;           
                            [moviePlayer prepareToPlay];    
                                 [moviePlayer play];

                                 [[NSNotificationCenter defaultCenter] addObserver:self
                                                                          selector:@selector(aMoviePlaybackComplete:)
                                                                              name:MPMoviePlayerPlaybackDidFinishNotification
                                                                            object:moviePlayer];
                                 [[NSNotificationCenter defaultCenter] addObserver:self
                                      selector:@selector(loadStateChanged:) name:MPMoviePlayerPlaybackStateDidChangeNotification   object:moviePlayer];                
              urlIndex++;    
                             }

                        }else
                        {
                                [[NSNotificationCenter defaultCenter]removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
                                [[NSNotificationCenter defaultCenter]removeObserver:self name:MPMoviePlayerPlaybackStateDidChangeNotification object:moviePlayer];
                                [player.view removeFromSuperview];                
                            }
  }

我的(更新的)代码:

// -> month marked days storage structures

typedef gint _month[31];

typedef struct month_all {
  _month jan;
  _month feb;
  _month mar;
  _month apr;
  _month may;
  _month jun;
  _month jul;
  _month aug;
  _month sep;
  _month oct;
  _month nov;
  _month dec;
} months;

// -> general structure

typedef struct signal_map {
  widgets widg;
  months mnt;
} signal_map_data;

但是如何才能获得单日(如同一个月的void load_marked_days (gint month, signal_map_data *smd){ #ifdef debug g_print ("-> load_marked_days\n"); #endif char buf[100]; sprintf (buf, "%d", smd->mnt.jan[0]); g_print (buf); } // ----------------- main ----------------- / int main (int argc, char *argv[]){ GtkBuilder *gtkBuilder; signal_map_data smd; gtk_init (&argc, &argv); gtkBuilder = gtk_builder_new (); gtk_builder_add_from_file (gtkBuilder, "gui.glade", NULL); smd.widg.wmw.wnd = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "wnd") ); smd.widg.wmw.btn_new = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "btn_new") ); smd.widg.wmw.btn_open = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "btn_open") ); smd.widg.wmw.btn_save = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "btn_save") ); smd.widg.wmw.btn_add = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "btn_add") ); smd.widg.wmw.btn_delete = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "btn_delete") ); smd.widg.wmw.tb_imgpath = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "tb_imgpath") ); smd.widg.wmw.btn_path = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "btn_path") ); smd.widg.wmw.btn_make = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "btn_make") ); smd.widg.wmw.calendar = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "calendar") ); smd.widg.wmw.img_month = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "img_month") ); smd.widg.wmw.combobox1 = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "combobox1") ); smd.widg.wmw.treeview = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "treeview") ); smd.widg.wdaw.dlg_add = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "dlg_add") ); smd.widg.wdaw.lb_q = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "lb_q") ); smd.widg.wdaw.tb_text = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "tb_text") ); smd.widg.wdaw.combobox2 = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "combobox2") ); smd.widg.wdaw.btn_select_add = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "btn_select_add") ); smd.widg.wdaw.btn_cancel_add = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "btn_cancel_add") ); smd.widg.wdbw.dlg_browse = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "dlg_browse") ); smd.widg.wdbw.btn_open_folder = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "btn_open_folder") ); smd.widg.wdbw.btn_cancel_browse = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "btn_cancel_browse") ); smd.widg.wdow.dlg_open = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "dlg_open") ); smd.widg.wdow.btn_open_file = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "btn_open_file") ); smd.widg.wdow.btn_cancel_open = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "btn_cancel_open") ); smd.widg.wdsw.dlg_save = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "dlg_save") ); smd.widg.wdsw.btn_save_file = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "btn_save_file") ); smd.widg.wdsw.btn_cancel_save = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "btn_cancel_save") ); smd.widg.lst.lst1 = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "liststore1") ); smd.widg.lst.lst2 = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "liststore2") ); smd.widg.lst.lst3 = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "liststore3") ); memset (smd.mnt.jan, 0, sizeof smd.mnt.jan); memset (smd.mnt.feb, 0, sizeof smd.mnt.feb); memset (smd.mnt.mar, 0, sizeof smd.mnt.mar); memset (smd.mnt.apr, 0, sizeof smd.mnt.apr); memset (smd.mnt.may, 0, sizeof smd.mnt.may); memset (smd.mnt.jun, 0, sizeof smd.mnt.jun); memset (smd.mnt.jul, 0, sizeof smd.mnt.jul); memset (smd.mnt.aug, 0, sizeof smd.mnt.aug); memset (smd.mnt.sep, 0, sizeof smd.mnt.sep); memset (smd.mnt.oct, 0, sizeof smd.mnt.oct); memset (smd.mnt.nov, 0, sizeof smd.mnt.nov); memset (smd.mnt.dec, 0, sizeof smd.mnt.dec); char buf[100]; sprintf (buf, "%d", smd.mnt.jan[0]); g_print (buf); gtk_builder_connect_signals (gtkBuilder, &smd); g_object_unref (G_OBJECT (gtkBuilder) ); g_timeout_add (1000, (GSourceFunc) load_marked_days, &smd); )以获得它的价值?

这来自_month[0]内部错误:

load_marked_days
  

-163321601

char buf[100];
sprintf (buf, "%d", smd->mnt.jan[0]);
g_print (buf);
  

4201655

如何获得我的价值???两者都不返回char buf[100]; sprintf (buf, "%d", &smd->mnt.jan[0]); g_print (buf); ... 但在我的主要功能中,这个“日”的打印工作并打印0 ..? 我的指针错了什么?

1 个答案:

答案 0 :(得分:0)

解决方案:超时提供所有参与者的回叫功能需求。 PRINT_OUT代码在其他地方工作。这是我内心的错误!!! - Martin Fischer