문제

In simulator i will get the obj files from bundle:

NSArray *myArray = [[NSBundle mainBundle] pathsForResourcesOfType:@"obj" inDirectory:nil];

In simulator the obj files are printed alphabetical order:

/Users/name/Library/Application Support/iPhone Simulator/6.0/Applications/10FF2D60-7B33-4AE9-9CA2-95A951A55C49/3DModels.app/**banana.obj**,

/Users/name/Library/Application Support/iPhone Simulator/6.0/Applications/10FF2D60-7B33-4AE9-9CA2-95A951A55C49/3DModels.app/**plane3.obj**,

/Users/name/Library/Application Support/iPhone Simulator/6.0/Applications/10FF2D60-7B33-4AE9-9CA2-95A951A55C49/3DModels.app/**wolverine.obj**,

/Users/name/Library/Application Support/iPhone Simulator/6.0/Applications/10FF2D60-7B33-4AE9-9CA2-95A951A55C49/3DModels.app/**Wteapot.obj**,

/Users/name/Library/Application Support/iPhone Simulator/6.0/Applications/10FF2D60-7B33-4AE9-9CA2-95A951A55C49/3DModels.app/**XBODY.obj**,

/Users/name/Library/Application Support/iPhone Simulator/6.0/Applications/10FF2D60-7B33-4AE9-9CA2-95A951A55C49/3DModels.app/**YLID.obj**
)

But ipad the obj files are not printed alphabetical order.

/Users/name/Library/Application Support/iPhone Simulator/6.0/Applications/10FF2D60-7B33-4AE9-9CA2-95A951A55C49/3DModels.app/**wolverine.obj,**

/Users/name/Library/Application Support/iPhone Simulator/6.0/Applications/10FF2D60-7B33-4AE9-9CA2-95A951A55C49/3DModels.app**/**Wteapot.obj**,**

/Users/name/Library/Application Support/iPhone Simulator/6.0/Applications/10FF2D60-7B33-4AE9-9CA2-95A951A55C49/3DModels.app/**plane3.obj**,

What is the problem?

도움이 되었습니까?

해결책 2

I think some of your obj file name starting character is in capital letter. just change those file names starting character is in small letter.

다른 팁

Apple Document of pathsForResourcesOfType:inDirectory: says that:

An array containing the full pathnames for all bundle resources matching the specified criteria. This method returns an empty array if no matching resource files are found.

It means Apple doesn't say that it will give you path in any particular order but if you need it in some order than you can sort by yourself.

NSArray *sorted = [myArray sortedArrayUsingComparator:^NSComparisonResult(NSString *str1, NSString *str2) 
{
    return [s1 localizedCaseInsensitiveCompare:s2];
}];

So now you have sorted NSArray of all paths.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top