在开发iPhone应用程序时,我很难将c ++和objective-c结合起来.我在应用程序中使用了第三方库.我有一个计划使用c或c ++来包装库,然后使用objective-c来调用它.用c ++完成课程后,我在objective-c中使用它时遇到了麻烦.有没有示例代码?谢谢.
在objective-c头文件中.我写
#import <UIKit/UIKit.h>
#import "ZJTConstants.h"
#include "TTSAdapter.h"
class Adapter;
@interface ZJTVBlogViewController : UIViewController {
@private
Adapter* adapter;
}
@end
Run Code Online (Sandbox Code Playgroud)
在mm文件中,我写道:
if (self) {
adapter = Adapter::getInstance();
// Custom initialization
}
Run Code Online (Sandbox Code Playgroud)
是写吗?
我试图通过fopen创建一个文件然后写它,但奇怪的事情发生了.
我使用fopen来创建文件.在我的情况下,我应该这样做来创建然后写文件.调用是fopen(pcm_output,"wb +");
我现在在应用程序中使用本地通知,但我发现一些奇怪的东西.
我设置并安排了这样的通知.
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil) {
return;
}
NSDate *now = [[NSDate alloc] init];
now = [now dateByAddingTimeInterval:dayToFinish * 24 * 60 * 60];
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSHourCalendarUnit fromDate:now];
components = [[NSCalendar currentCalendar] components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit fromDate:now];
int month = [components month];
int day = [components day];
int year = [components year];
NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
NSDateComponents *dateComps = [[NSDateComponents alloc] init];
[dateComps setYear:year];
[dateComps setMonth:month];
[dateComps setDay:day]; …
Run Code Online (Sandbox Code Playgroud)