小编Sub*_*bbu的帖子

iPhone - 如何检查文件是目录,音频,视频还是图像?

我的程序显示Documents目录的内容并显示在tableView中.但Documents目录包含一些目录,一些音频,一些视频和一些图像等.

NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsDir = [dirPaths objectAtIndex:0];
fileType = @"" ;
NSString *subDirectoryPath = [docsDir stringByAppendingPathComponent:fileType];
NSLog(@"path : %@",subDirectoryPath);
files  = [[NSMutableArray alloc] initWithArray:[[NSFileManager defaultManager] contentsOfDirectoryAtPath:subDirectoryPath error:nil]];
NSLog(@"files ::::: %@ ",[files description]);
Run Code Online (Sandbox Code Playgroud)

所以,我想检查文件是否是目录,然后它的目录图像可以显示在单元格的imageView中.音频,视频和图像也是如此.

我在NSFileManager classReference中搜索过,但是dint得到了一个解决方案.

这该怎么做 ?

iphone nsfilemanager ios

35
推荐指数
1
解决办法
2万
查看次数

委托函数与回调函数

我在iOS平台上工作,我想知道什么是委托函数,什么是回调函数?这两种功能有什么区别,或者它们是一样的?

委托函数的示例numberOfRowsInSectionUITableViewDelegate协议中,回调函数的示例didReceiveLocalNotificationappDelegate.m

我们可以在Objective-C中创建自己的回调函数,如果是,举个例子......

谢谢..

delegates objective-c callback ios

14
推荐指数
1
解决办法
2万
查看次数

手动从OS磁盘EBS卷创建AMI所需的更改

我有一个VMware VM其OS原始磁盘备份到AWS S3.我可以AMI从OS盘创建使用import-image.我不能import-image每次都使用,因为它非常慢,因为我正在创建一个应用程序,您可以将VM备份到AWS云,其中第一个备份将是FULL备份,这需要更长时间,但后续INCREMENTAL备份应该花费更少的时间(取决于数据量已更改).我在每次备份期间创建AMI,即FULL或INCREMENTAL备份.

因此,可以解释的是,FULL备份需要时间,但对于INCREMENTAL,它应该花费更少的时间.

问题是,在增量备份期间从RAW数据创建AMI时,AWS不知道在FULL备份期间已经创建了AMI(以及相应的EBS快照),应该使用(或比较)最新数据来查找数据更改因此,应仅从更改的数据中创建AMI,这将花费更少的时间.

所以,我有以下选择:

1)import-snapshotAPI =将原始操作系统磁盘转换为EBS snapshot文件.

2)复制OS磁盘数据=创建EBS volume并将其附加到正在运行的磁盘上EC2 instance.然后将所有OS磁盘原始数据复制到卷.然后从中创建快照EBS volume.从EBS snapshot,我们可以创造AMI.

我尝试了两种选择,但每次尝试从中启动EC2 instanceAMI,都会出现以下错误:

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(8,0)
Run Code Online (Sandbox Code Playgroud)

通过各种论坛会后,我才知道,如果有错配出现上述错误AKI,并ARI同时从快照创建AMI.正确的AKI和ARI是从创建快照的源EC2实例中获取的(因为这是AWS所期望的).

就我而言,我没有从正在运行EC2 instance但从VMWare VM OS磁盘创建快照.

我发现import-imageAPI在创建AMI时也会创建快照.因此,我比较了import-image创建的快照和我使用option-1和option-2创建的快照.

我比较了文件列表 …

bootable amazon-ec2 amazon-web-services aws-ebs amazon-ami

7
推荐指数
0
解决办法
241
查看次数

connect:连接在客户端的c程序中被拒绝

我使用以下代码连接到某个端口的服务器,这些端口作为命令行参数提供...

#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <errno.h>
#include <stdlib.h>
#include <strings.h>

int main(int argc,char *argv[])
{
   struct sockaddr_in serverAddr;
   int clientSocketFd ;
   char buffer[1024];

 if((clientSocketFd = socket(AF_INET, SOCK_STREAM, 0))==-1)
    perror("socket");

//get the server IP address and PORT
bzero(&serverAddr, sizeof serverAddr);
printf("ip address :- %s\n",argv[1]);
inet_pton(AF_INET, argv[1], &(serverAddr.sin_addr));
serverAddr.sin_family=AF_INET;
serverAddr.sin_port = atoi(argv[2]);

printf("PORT :- %d\n",serverAddr.sin_port);
//connect to server
if(connect(clientSocketFd,(struct sockaddr *) &serverAddr, sizeof(serverAddr)) == -1)
    perror("connect");

printf("Connecting to the server %s on port …
Run Code Online (Sandbox Code Playgroud)

c sockets

1
推荐指数
1
解决办法
1万
查看次数

strcpy()无法正常工作

我目前正在编写一个程序,其中我陷入了strcpy()函数的另一种行为.这是它的简短演示......

我经历了以下问题:从C字符串中删除第一个和最后一个字符

//This program checks whether strcpy() is needed or not after doing the modification in the string 
#include <stdio.h>
#include <string.h>

int main()
{
        char mystr[] = "Nmy stringP";
        char *p = mystr ;
        p++;

        p[strlen(p)-1] = '\0';
        strcpy(mystr,p);
        printf("p : %s mystr: %s\n",p,mystr);

}
Run Code Online (Sandbox Code Playgroud)

输出: -

p : y strnng mystr: my strnng
Run Code Online (Sandbox Code Playgroud)

如果我不使用strcpy()函数,那么我得到

p : my string mystr : Nmy string 
Run Code Online (Sandbox Code Playgroud)

为什么会这样?

c string strcpy

1
推荐指数
1
解决办法
2613
查看次数

第二次寻求不工作

在我的下面的代码中,我计算单词,行数,然后计算文本文件的大小.第一次使用seekg在第一次while循环之后工作正常但在第二次while循环之后,它不起作用.它给出了输出中显示的值.

#include <iostream>
#include <fstream>
using namespace std ;

int main(void)
{
    fstream  txtFile;
    txtFile.open("test.txt");

    if(txtFile.is_open())
    {
        printf("txt file is opened");
    }

    //number of words and lines in txt file
    int w=0 , l =0 ;
    int c , start , end;
    string s;

    while(1)
    {
        if(txtFile.peek() == -1)
            break;
        c = txtFile.get();
        if(c != txtFile.eof())
                    w++;
    }

    txtFile.seekg(0,ios::beg);

    while(getline(txtFile,s))
    {
         l++ ;
    }
    printf("no of words : %d , no of  lines: %d\n",w,l); …
Run Code Online (Sandbox Code Playgroud)

c++ file-io

1
推荐指数
1
解决办法
1181
查看次数

通过引用呼叫的行为

在我的程序中,我传递一个指向函数的指针.在该函数中,我将传递的指针指向另一个指针所指向的位置.从函数返回时,它不再指向其新位置,而是指向其原始位置.当我通过参考调用时,它应该指向它的新位置.为什么会这样?

// a program to show behavior of call by reference

#include <stdio.h>
#include <stdlib.h>

void ptrAllocation(int *p)
{
    int k = 10 ;
    int *t = &k;
    p = t ;
    printf("\np now points : %d",*p);
}

int main()
{
    int i = 5 ;
    int *a = &i;
    ptrAllocation(a);
    printf("\na now points : %d",*a);
}
Run Code Online (Sandbox Code Playgroud)

输出:

p now points : 10
a now points : 5
Run Code Online (Sandbox Code Playgroud)

我知道如果我做一个像下面这样的函数可以解决问题:

void ptrAllocation(int **p)
{
    int k = 10 ;
    int *t …
Run Code Online (Sandbox Code Playgroud)

c pointers pass-by-reference

0
推荐指数
1
解决办法
273
查看次数