出于调试目的,我想在运行时以类似于App Store上的Console app(可在此处找到)的方式访问控制台打印输出.
我做了一些搜索文档,我找不到Apple提供的任何东西,但我觉得我错过了一些重要的东西.任何见解?
谢谢.
我正在使用我的[[UIDevice currentDevice] uniqueIdentifier]所有应用程序,Apple不再允许使用它uniqueIdentifier.我需要一些东西来代替uniqueIdentifier我用来识别用户的东西,即使用户删除了应用程序并再次安装它,(并且还得到苹果批准我的应用程序).
谢谢
我正在观看有关使用XCode和Heroku创建iOS应用的视频.在zsh中键入以下命令:
pod install
Run Code Online (Sandbox Code Playgroud)
我想知道是否有人可以解释这是什么以及它用于什么?简单的概述就足够了.
我在一个iPad应用程序上工作,该应用程序具有一个紧密循环使用Web服务和Core Data的同步过程.为了根据Apple的Recomendation减少内存占用,我会NSAutoreleasePool定期分配和排空.这当前效果很好,当前应用程序没有内存问题.但是,我打算转移到NSAutoreleasePool不再有效的ARC,并希望保持同样的性能.我创建了一些示例并计算了它们,我想知道使用ARC的最佳方法是什么,以实现相同的性能并保持代码可读性.
出于测试目的,我想出了3个场景,每个场景使用1到10,000,000之间的数字创建一个字符串.我运行了每个例子3次,以确定他们使用带有Apple LLVM 3.0编译器(w/o gdb -O0)和XCode 4.2的Mac 64位应用程序花了多长时间.我还通过仪器运行每个示例,以大致了解内存峰值.
以下每个示例都包含在以下代码块中:
int main (int argc, const char * argv[])
{
@autoreleasepool {
NSDate *now = [NSDate date];
//Code Example ...
NSTimeInterval interval = [now timeIntervalSinceNow];
printf("Duration: %f\n", interval);
}
}
Run Code Online (Sandbox Code Playgroud)
NSAutoreleasePool批次[原始预ARC](峰值内存:~116 KB)
static const NSUInteger BATCH_SIZE = 1500;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
for(uint32_t count = 0; count < MAX_ALLOCATIONS; count++)
{
NSString *text = [NSString stringWithFormat:@"%u", count + 1U];
[text class]; …Run Code Online (Sandbox Code Playgroud) memory-management objective-c nsautoreleasepool ios automatic-ref-counting
我正在尝试将代码从AurioTouch项目移动到我的项目中.但我有很多错误:
Unknown type name 'class'; did you mean 'Class'?
Run Code Online (Sandbox Code Playgroud)
例如,在文件FFTBufferManager.h中:
#include <AudioToolbox/AudioToolbox.h>
#include <libkern/OSAtomic.h>
#include "SpectrumAnalysis.h"
class FFTBufferManager
{
public:
FFTBufferManager(UInt32 inNumberFrames);
~FFTBufferManager();
Run Code Online (Sandbox Code Playgroud)
我试图将编译器更改为LLVM GCC 4.2,但它会产生很多其他错误:
Expected '=', ',', ';', 'asm' or '__attribute__' before 'FFTBufferManager'
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我已经使用各种排序方法查看了几个答案NSMutableArray,但由于某种原因它们不适合我.
我只是试图通过Delay每个字典中的键对包含字典的可变数组进行排序.但是,"sorted"数组与原始数组完全相同.
顺便说一句,如果我创建一个虚拟可变数组并用包含数字的字典填充它,它可以正常工作,但由于某种原因它不会对我正在初始化的这个可变数组进行排序.
我究竟做错了什么?
这是我的代码:
playlistCalls = [[NSMutableArray alloc] initWithArray:[currentPlaylist objectForKey:@"Tunes"]];
NSLog(@"original %@", playlistCalls);
NSSortDescriptor *delay = [NSSortDescriptor sortDescriptorWithKey:@"Delay" ascending:YES];
[playlistCalls sortUsingDescriptors:[NSArray arrayWithObject:delay]];
NSLog(@"sorted %@", playlistCalls);
Run Code Online (Sandbox Code Playgroud)
这是包含字典的数组:
2012-06-04 15:48:09.129 MyApp[57043:f503] original (
{
Name = Test Tune;
Delay = 120;
Volume = 100;
},
{
Name = Testes;
Delay = 180;
Volume = 100;
},
{
Name = Testing;
Delay = 60;
Volume = 100;
}
)
2012-06-04 15:48:09.129 MyApp[57043:f503] sorted (
{
Name = Test …Run Code Online (Sandbox Code Playgroud) 所以我有一个简单的用户界面,一个开始按钮,一些文本/标签和一个进度条.单击"开始"按钮时,NSProgressIndicator 应设置动画.这是我的代码:
@synthesize progressBar = progressBar;
/* Some code and setup stuffs... */
- (IBAction)startAction:(id)sender {
NSLog(@"Button clicked.");
NSLog(@"Beginning Socketry and socket creation...");
[progressBar setUsesThreadedAnimation:YES];
[progressBar setIndeterminate:YES];
[progressBar startAnimation:progressBar];
}
Run Code Online (Sandbox Code Playgroud)
我检查了多个源(Apple Developer Portal等),但没有任何效果.我不必拥有NSPIndicator,但如果可以的话,它会非常好.另外,这是我的AppDelegate.h文件:
#import <Cocoa/Cocoa.h>
@interface AppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (weak) IBOutlet NSProgressIndicator *progressBar;
- (IBAction)saveAction:(id)sender;
- (IBAction)startAction:(id)sender;
- (IBAction)changeStatus:(id)sender;
- (IBAction)changeProgress:(id)sender;
@end
Run Code Online (Sandbox Code Playgroud) 我在应用程序中使用嵌套的NSTimer.我这里有两个问题.
- (void)updateLeftTime:(NSTimer *)theTimer- (void)updateLevel:(NSTimer *)theTimer也是由计时器调用.- (void)viewDidLoad {
[super viewDidLoad];
tmLevel=[NSTimer scheduledTimerWithTimeInterval:20.0f target:self selector:@selector(updateLevel:) userInfo:nil repeats:YES];
tmLeftTime=[NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(updateLeftTime:) userInfo:nil repeats:YES];
}
- (void)updateLevel:(NSTimer *)theTimer {
static int count = 1;
count += 1;
lblLevel.text = [NSString stringWithFormat:@"%d", count];
tfLeftTime.text=[NSString stringWithFormat:@"%d",ANSWER_TIME];
tmLeftTime=[[NSTimer alloc] init];
tmLeftTime=[NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(updateLeftTime:) userInfo:nil repeats:YES];
[self playMusic];
}
- (void)updateLeftTime:(NSTimer *)theTimer {
static int timeCounter=1;
timeCounter+=1;
tfLeftTime.text=[NSString stringWithFormat:@"%d", (ANSWER_TIME-timeCounter)];
}
Run Code Online (Sandbox Code Playgroud) void main() {
void strrev(char *);
char *p="GOOd";
strrev(p);
printf("%s",p);
}
void strrev(char *str) {
char temp, *end_ptr;
if( str == NULL || !(*str) ) return;
end_ptr = str + strlen(str) - 1;
while( end_ptr > str )
{
temp = *str;
*str = *end_ptr;
*end_ptr = temp; str++;
end_ptr--;
}
}
Run Code Online (Sandbox Code Playgroud)
我得到错误分割失败可以任何人帮助我如何解决它...
我们需要检查2个阵列是否相似.元素也可以是重复的.例如,A = {2,3,4,5,6,6}和B = {3,6,2,4,6,5}是相似的.
我有一个天真的解决方案:
foreach i:int in arr1
foreach j:int in arr2
{
if(i == j)
j = -1;
}
Run Code Online (Sandbox Code Playgroud)
现在,如果j的所有元素都是-1,那么我们可以说2个数组是相似的.有人可以提供一个不起作用的测试用例(我希望它应该工作!)?
这也是O(n ^ 2).我们可以做得更好吗?不允许排序和散列.